Last active
July 21, 2020 20:38
-
-
Save usimsek/60094d4f8453151b581aeeda6053902f to your computer and use it in GitHub Desktop.
flutter mobile screen info // (tr) flutter mobil cihazların ekran çözünürlüğünü verir
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'; | |
class CommonThings { | |
static Size width; | |
static Size height; | |
} | |
void main() => runApp(new MyApp()); | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
title: 'MediaQuery Demo', | |
theme: new ThemeData( | |
primarySwatch: Colors.red, | |
), | |
home: new MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
CommonThings.width = MediaQuery.of(context).size; | |
CommonThings.height = MediaQuery.of(context).size; | |
print('Width of the screen: ${CommonThings.width.width},'); //mobile screen width | |
print('heigtht of the screen: ${CommonThings.height.height},'); //mobile screen height | |
return new Container(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment