Flutter web how to get full screen size

Issue

I’m using MediaQuery.of(context).size.height to get screen size (height in this case) of my flutter web as we do in mobile, but when I shrink chrome (aka web browser), MediaQuery value is converts to shrunk screen size, what I want is fixed screen size which is equal to screen size of full screen. Can I do that ?

Thank-you

Solution

Just use SizedBox to force the screen size if it below minimum.

final size = MediaQuery.of(context).size;
final minWidth = 800.0;
final minHeight = 600.0;

SizedBox(
  width: size.width < minWidth ? minWidth : size.width,
  height: size.height < minHeight ? minHeight : size.height,
  child: const Card(child: Text('Hello World!')),
);

Answered By – Alann Maulana

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *