Last active
March 29, 2020 20:01
-
-
Save carzacc/62ddf21fb01a9c56b840323cff8df14e to your computer and use it in GitHub Desktop.
Example of Flutter app using the MediaQuery to get constraints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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