which is the best technique for responsive flutter - 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

Related

Using a LayoutBuilder with Slivers

I use a layoutbuilder in flutter to create a responsive design. However, lately I've gotten into slivers and the layoutbuilder does not work with them by default. I've found a sliverlayoutbuilder class, but it does not appear to have the width I'm looking for.
What's the best way to get width when using slivers?

Flutter different screen size

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!!

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.

How can I get the height of a flutter widget?

How can I get the height of a flutter widget? I think it's using key, but I don't know how.
For example I want to get the height of a container, which will be in a stack to be able to put the padding of a list view and that at the initial moment it is under the container.
If you’re wanting to get the height before the children widget are built, use a LayoutBuilder widget to wrap the descendants.
Otherwise you can also check the dev tools by using the Select Wifget tool and looking at the widget”s properties

Percentage based layouts in Flutter

Coming from an Android background I'm used to using ConstraintLayout to define percentage based margins and sizes for my UI. I was wondering if there is a widget in Flutter that can achieve something similar. I've been looking at the widget documentation but I haven't found anything yet.
In flutter, percentage sizes are represented using FractionalOffset which is basically 0 < {x,y} < 1 coordinates
There are a few widgets available using this logic, like:
FractionallySizedBox
Align
These, combined with a stack should allow about any layout you need without using LayoutBuilder or similar.