Skip to content

Instantly share code, notes, and snippets.

@rapPayne
Created March 10, 2024 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rapPayne/9fd2f7380f05b4d4bfaf83969a9b8681 to your computer and use it in GitHub Desktop.
Save rapPayne/9fd2f7380f05b4d4bfaf83969a9b8681 to your computer and use it in GitHub Desktop.
Flutter responsive scrolling
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: ResponsiveImageAndDescription(),
),
);
}
}
class ResponsiveImageAndDescription extends StatelessWidget {
final String loremIpsum =
'Co-founder Flutter Study Group on Slack. Writing code for 20+ years, now at DevAngels, London. Mainly @flutter, and @android also @golang.. but ❤️ Flutter. We are passionate about bringing your vision to life, brilliantly, on all platforms. DevAngels is more than a dev-team-for-hire: we are here to partner directly with your business, so that you dont need to make permanent hires for CTO and software engineering - instead, let us be your CTO-as-a-service!';
@override
Widget build(BuildContext context) {
bool isPortrait =
MediaQuery.of(context).orientation == Orientation.portrait;
return Flex(
direction: isPortrait ? Axis.vertical : Axis.horizontal,
children: [
Image.network(
'https://miro.medium.com/v2/1*gK8YRfgcTa6_WELIBdwe8Q.jpeg'),
Column(children: [
Text('Some needed text'),
Text(loremIpsum),
Text('Some more needed text'),
]),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment