Resizing class according to screen size on flutter

Issue

I’m new to flutter,I’ve designed my app using fixed dimensions.
What’s the easiest way to resize scaffold according to screen size (different phone screen size).

Solution

You can use MediaQuery.of(context).size inside build method.

build(BuildContext) {
   final Size size = MediaQuery.of(context).size;
}

Then use it like this:

SizedBox(
   height: size.height,
   width: size.width * 0.85,
),

Another options are using external libraries like GetX or ScreenUtils

Answered By – Hazar Belge

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

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