Skip to content

Instantly share code, notes, and snippets.

@carzacc
Last active March 29, 2020 20:01
Show Gist options
  • Save carzacc/62ddf21fb01a9c56b840323cff8df14e to your computer and use it in GitHub Desktop.
Save carzacc/62ddf21fb01a9c56b840323cff8df14e to your computer and use it in GitHub Desktop.
Example of Flutter app using the MediaQuery to get constraints
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(context) =>
MaterialApp(
home: MyHomePage()
);
}
class MyHomePage extends StatelessWidget {
@override
Widget build(context) =>
Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
"Width: ${MediaQuery.of(context).size.width}",
style: Theme.of(context).textTheme.headline4
),
Text(
"Height: ${MediaQuery.of(context).size.height}",
style: Theme.of(context).textTheme.headline4
)
]
)
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment