Last active
March 22, 2020 19:34
-
-
Save mslimani/93e9307b370ca1e77e3178e23b03af6d to your computer and use it in GitHub Desktop.
Ineat Flutter #3 - MediaQuery
This file contains 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(MaterialApp( | |
home: Screen(), | |
)); | |
} | |
class Screen extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
var mediaQueryData = MediaQuery.of(context); | |
final width = mediaQueryData.size.width; | |
final height = mediaQueryData.size.height; | |
final orientation = mediaQueryData.orientation.toString(); | |
return Scaffold( | |
body: Center( | |
child: Text( | |
"$width x $height\n$orientation", | |
textAlign: TextAlign.center, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment