You can get the width and height of the Screen through MediaQuery.Size property.
Here is the code snippet from which you can get the width and height of the screen of the phone.
final sizeX = MediaQuery.of(context).size.width;
final sizeY = MediaQuery.of(context).size.height;
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Rows and Columns'),
),
body:
Home(),
),
);
}
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
final sizeX = MediaQuery.of(context).size.width;
final sizeY = MediaQuery.of(context).size.height;
return Container(
color: Colors.red,
width: sizeX,
height: sizeY,
child:
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text('Width: $sizeX' ),
Text('HeiGht: $sizeY' ),
],
)
);
}
}
Hope this helps.
Thanks,
Srikanth