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).
-
1You need to research first if you do not find this solution then post it here. Please read this article stackoverflow.com/help/how-to-ask– Jahidul IslamAug 31, 2021 at 11:18
-
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.– Community BotSep 2, 2021 at 19:37
4 Answers
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
You go through official documentation here
And use MediaQuery.of() Responsive, Adaptive classes/Widgets
To resize your screens/widgets you can use MediaQuery.
You can use it like ->
screenHeight: MediaQuery.of(context).size.height,
screenWidth: MediaQuery.of(context).size.width,
Then you can scale it like ->
Container(
width: MediaQuery.of(context).size.width* 0.5,
)
If you multiply with 0.5, that means, you want to use 50% of screen width.
Packages and sources :
https://pub.dev/packages/responsive_framework https://flutter.dev/docs/development/ui/layout/adaptive-responsive
You can check height and width by MediaQuery. Example :
double _height = MediaQuery.of(context).size.height;
double _width = MediaQuery.of(context).size.width;