How can we apply this on bigger app structure with complex widgets I can't duplicate the views one for portirat and one for landscape for the whole app widgets
That is a really good point, in some of my Live Streams I started by creating a "Responsive Widget" which allowed me to initialize it for 3 different screen sizes, with that I was able to use the same widgets with different information. FilledStacks created a fantastic series already with mutliple ways on how to implement a Responsive Architecture, maybe this will guide you along the way. www.filledstacks.com/tag/Responsive%20UI/
Thank you, just a quick question regarding the orientation depending on the ternary in Scaffold. As HomeScreen widget is a stateless widget, how does it re-render when the device is switched from portrait to landscape?
That is related to the underling implementation of MediaQuery.of it uses the build method where it is inside as a reference (thanks to MediaQuery.of(context) it knows exactly in which widget it is inside. Therefore it can retrigger the rebuild as soon as it understands the changes. In the API it is not fully explained but you see that it is created with the intention that it triggers the rebuild. api.flutter.dev/flutter/widgets/MediaQuery-class.html I hope that helps :)
1 question buddy. What does constrain width return does it return it's parent widget width or screen width ? If I have Container its width is 200 and child is layoutbuilder so constraints.maxwidth will be 200?
Hi Nikhil, yes exactly. The constraints take the width and height of its parent widget, which in your case will be the Container widget with width 200.
Sir, So for like portrait and landscape we don't have any other class where it Automatically set the 5 cards with best fit? It would be hectic to design portrait and landscape for every Screen! Love from India!!
Good point unfortunately this is how flutter works I use in the Flutter website a Responsive Widget to make it possible to use the right widget depending on the situation.
Keep in mind everything in flutter can run in web so it will have some sort of common widget for things you'd like to do. Check out the flexible widget.
Hi Prashant Kumar, thanks for the question. The MediaQuery contains valuable information about the Orientation and the ScreenSize, and if you use the MediaQuery.of method, it retriggers the build method automatically again. Also, the MediaQuery can distinguish without returning a widget and, you can change only properties of font sizes. api.flutter.dev/flutter/widgets/MediaQuery-class.html The LayoutBuilder gives us additionally the BoxConstraints of the Widget it lives inside. Additionally, the LayoutBuilder needs necessarily to return a widget. api.flutter.dev/flutter/widgets/LayoutBuilder-class.html I hope that solved your question if not please feel free to DM me and I will try to give you a better explanation.
I made this differently SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown ]); but I like your solution more, so I have to remake mine, thanks
Well explained with examples. Clear voice. Thank your for this great video.
Thank You, dear sir!
Ohh thank you so much for this video
You are most welcome :)
Nicely explained.. 👌
amazing work and explanation, keep it up and best of luck
Thanks, will do!
Great video, keep it up!
Thanks for your support! I will give my best :).
Hey, thank you for this great tutorial. It helped me a lot
thank u sir
You are most welcome :)
How can we apply this on bigger app structure with complex widgets
I can't duplicate the views one for portirat and one for landscape for the whole app widgets
That is a really good point, in some of my Live Streams I started by creating a "Responsive Widget" which allowed me to initialize it for 3 different screen sizes, with that I was able to use the same widgets with different information.
FilledStacks created a fantastic series already with mutliple ways on how to implement a Responsive Architecture, maybe this will guide you along the way.
www.filledstacks.com/tag/Responsive%20UI/
Thank you so much I already saw 3 videos I will follow his instructions
@@mohamedelyamani7845 Fantastic :) enjoy the journey!
Thank you, just a quick question regarding the orientation depending on the ternary in Scaffold. As HomeScreen widget is a stateless widget, how does it re-render when the device is switched from portrait to landscape?
That is related to the underling implementation of MediaQuery.of it uses the build method where it is inside as a reference (thanks to MediaQuery.of(context) it knows exactly in which widget it is inside. Therefore it can retrigger the rebuild as soon as it understands the changes. In the API it is not fully explained but you see that it is created with the intention that it triggers the rebuild.
api.flutter.dev/flutter/widgets/MediaQuery-class.html
I hope that helps :)
@@FlutterExplained Thanks, it does indeed. So, MediaQuery should be used with caution to prevent unnecessary rebuilds.
Hello, your code about MediaQuery gave me an error "No MediaQuery widget ancestor found.", what is the reason for that
1 question buddy.
What does constrain width return does it return it's parent widget width or screen width ?
If I have Container its width is 200 and child is layoutbuilder so constraints.maxwidth will be 200?
Hi Nikhil, yes exactly. The constraints take the width and height of its parent widget, which in your case will be the Container widget with width 200.
Sir, So for like portrait and landscape we don't have any other class where it Automatically set the 5 cards with best fit? It would be hectic to design portrait and landscape for every Screen! Love from India!!
Good point unfortunately this is how flutter works I use in the Flutter website a Responsive Widget to make it possible to use the right widget depending on the situation.
Keep in mind everything in flutter can run in web so it will have some sort of common widget for things you'd like to do. Check out the flexible widget.
When should we use MediaQuery and LayoutBuilder in a screen
Hi Prashant Kumar, thanks for the question.
The MediaQuery contains valuable information about the Orientation and the ScreenSize, and if you use the MediaQuery.of method, it retriggers the build method automatically again. Also, the MediaQuery can distinguish without returning a widget and, you can change only properties of font sizes.
api.flutter.dev/flutter/widgets/MediaQuery-class.html
The LayoutBuilder gives us additionally the BoxConstraints of the Widget it lives inside. Additionally, the LayoutBuilder needs necessarily to return a widget.
api.flutter.dev/flutter/widgets/LayoutBuilder-class.html
I hope that solved your question if not please feel free to DM me and I will try to give you a better explanation.
I made this differently
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown
]);
but I like your solution more, so I have to remake mine, thanks
I did it before I discovered the Media Queries orientation exactly in the same way :). It is easier to prototype I guess.