I designed simple Flutter android application, after building Apk I installed that apk in others android mobiles phones for testing, but I am facing issues, Screens size is varies, widgets positions, button inside text , alignments also changed in other phones screens, but My mobile its showing correctly, I tried in 2 Mobiles , 1st mobile screen size is large compare to my phone size. 2nd mobile screen is small compare to my mobile screen, Please suggest and guide how can I fix this issue. I want application all screens looks same in all type of mobile screens.
Thank you so much
3
Answers
You can use flutter_screenutil (A flutter plugin for adapting screen and font size.Let your UI display a reasonable layout on different screen sizes )
You could use relative sizes depending on the max screen size instead of using fixed sizes.
There are also packages for this like: https://pub.dev/packages/sizer
Because per default fixed size widgets like for example a
Container(width: 100, height: 100)
of course take a different percentage of the total available screen space depending on how large the screen is.But Flexible Widgets like
Expanded
inside of aColumn
already size their children to a fraction of the available space.Also some widgets like a
Text("Some long text...")
might fit on a single line on large devices, but wrap their content into two, or more lines on a smaller device.you can install this package and use it in your application it’s very popular and many of developers work with it
this is the link of the package: https://pub.dev/packages/flutter_screenutil
1_ install the package in pubspec.yaml in the dependencies
2_ import the package in main.dart
3_ wraps material app with screen_util and define the size that you want to work with :
4_ finally you can use it in any screen in your app to make it reponsive by adding .h to height and .w to width and .sp to fontsize .r to raduis like this :
now you can make your app responsive and change any screen or widget or text size based on the screen size of device that you using.