Skip to content

Instantly share code, notes, and snippets.

@mslimani
Last active March 22, 2020 19:34
Show Gist options
  • Save mslimani/93e9307b370ca1e77e3178e23b03af6d to your computer and use it in GitHub Desktop.
Save mslimani/93e9307b370ca1e77e3178e23b03af6d to your computer and use it in GitHub Desktop.
Ineat Flutter #3 - MediaQuery
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