Flutter different screen size - flutter

I'm working on a flutter project but having problem to make the widgets and texts to fit different phone screens. Tried looking for answers on youtube but I could not get any. Your help is appreciated. Thanks.rt

Here are some resources for your need.
For responsive layout,
https://medium.com/flutter-community/tagged/responsive-design
https://medium.com/#TidingsSP/flutter-responsive-widget-development-using-a-modular-approach-bf8d63838c76
https://pub.dev/packages/responsive_framework (responsive layout plugin)
https://pub.dev/packages/sizer (responsive layout plugin)
For responsive font,
https://pub.dev/packages/auto_size_text ( best option if you wanna resize font automatically based on parent widget's size )
For responsive widget,
Consider using Flexible, Expanded, MediaQuery.of(context).size.width, MediaQuery.of(context).size.height for widgets' dimensions instead of fixed sizes.
Use FittedBox, LayoutBuilder.
Have fun!!

Related

Is there a way to calculate a dynamically sized widget?

I'd like to add a custom showMore widget if the skills widget which has a dynamic size(width) exceeds the screen width. On clicking the showMore widget it should show all the skills in a wrap .else show less.
In flutter
Constraints go down and sizes go up
See this documentation.
Flutter uses a single pass algorithm to render your application. This is a technical choice to ensure performance but it comes with limitations.
One of them is that, when you are building the widget tree, you only have access to the constraints of the parent, and not any size of any widget (since they are not rendered yet).
So a short answer to your question is:
No, you cannot do what you are trying to do (displaying something if some widgets are not fitting on the screen) since you don't have access to any sizes in the build method.
An alternative solution would be to use Wrap to wrap your chips or use a ListView on the horizontal axis to make the list of chips horizontally scrollable.
Anyway, if you really want to do this, you can hardcode the sizes of your chip and access the device size with MediaQuery.of(context).size or by using the LayoutBuilder and using contraints.maxWidth as the parent's width. Then you can check whether or not numberOfChips * chipSize <= maxWidth. But I wouldn't recommend it as the design wouldn't be responsive:
All the chips will have the same size, so you'll end up with a big chip for "c" and maybe a long name like "python" won't fit in and you'll end up with overflow issues.
What if the user changes the font size of his device? You will also end up with overflow issues.

which is the best technique for responsive flutter

creating responsive widget kinda isMobile?Fontsize 12 : fontsize 24 or use sizer package,what is the best responsive method for web,tablet,mobile?
flutter documentation did give some solution but , not effective for all purposes
AspectRatio
CustomSingleChildLayout
CustomMultiChildLayout
FittedBox
FractionallySizedBox
LayoutBuilder
MediaQuery
MediaQueryData
OrientationBuilder
if we using one by one , all methods have it's own defects .
mobile side and tablet side it will work , but in the case of windows and web , it won't.
if we combine these methods , also get some responsive issue , because of all methods are depend on the device height ,device width ,device aspectRatio , device Offset ,
also so much plugins are available but they have defects too , in the case of flutter_screenutil it depend on width , height . so if changes in one of the property it won't count. that means it won't change layout in web
so i am using this way combine 4 methods together
flutter_screenutil , LayoutBuilder , MediaQuery , AspectRatio
by using this way we can achieve,maintain the 3 layouts in one code
please use wisely according to your use case
the best place to find FLUTTER solutions/documentations is the official flutter/dart websites.
For this question:
Creating responsive and adaptive apps

which class or widget to use a better responsive layout in the flutter?

This class or widget is useful to create a responsive layout.
AspectRatio
CustomSingleChildLayout,
CustomMultiChildLayout,
FittedBox,
FractionallySizedBox,
LayoutBuilder,
MediaQuery,
MediaQueryData,
OrientationBuilder.
Which is to use the better responsive layout.
iDecode already told you that it all depends on what you need. here take a look at official documentation, https://flutter.dev/docs/development/ui/layout.
And here is my advice
Use row when you need Horizontal layout
Use column when you need Vertical layout
Use singleChildScrollView when you need scrolling layout
Use either GridView or listView when you need repetitive view
Use Expanded, Flexible, Limitedbox, flexiblebox for adjusting the size of the widget
Mine favourite : Rows for Horizontal, Column for vertical, Scrollview for Extra data exist in the page or UI not fitted in the screen, ListView for TableView UI etc
For best fitting layout: IS Expanded, AspectRatio

cupertino option tiles ,ios settings page style

I'm wondering which or how can design settings page like that
1-every option has a own value in right if it's has
2-hit under tile option
3- the divider not full width
is it by ListTile !! or there is another widget ?
There are multiple widgets uses in the above design you can not create it with single widget
Widgets You can use
Text,Containers,ListTile,CupertinoButtons and more
Try yourself and Best of luck

how to zoom in & out in GWT

i created a widget, say MyBox, which has many other widgets. i have to use that widget on different page, however on different page, the size of the widget is different, on some page it's smaller, on other page it's bigger. Just wonder is there any way in GWT to zoom in & out the widget? Thanks
You can set the width and height of a widget, and the normal kinds of "zooming" that happen with HTML will happen to your widget too. If you want inner widgets to resize automatically, check out Layout Panels in GWT 2.0 and later.