Skip to content

Instantly share code, notes, and snippets.

@usimsek
Last active July 21, 2020 20:38
Show Gist options
  • Save usimsek/60094d4f8453151b581aeeda6053902f to your computer and use it in GitHub Desktop.
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
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