Hello And Welcome To 2A Channel
Ever found yourself writing a build method
and wished you could know
how big your widget was going to be
before you decided how it would look?
Well, LayoutBuilder can help.
Its builder function
has parameters for build context
and the incoming box constraints--
those are the valid width
and height ranges for the widget.
Your build logic can check those constraints
and then make smart decisions about how to compose itself.
add to center widget layoutBuilder widget
the builder takes two parameters context and constraints
return a container widget
add color parameter
add width parameter and use constraints from the builder will give us the max-width
if the constrains width bigger than 350-pixel container width will be 300
otherwise, container width will be 200 pixel
add height parameter and use constraints from the builder will give us the max-height
if the constrains width bigger than 500-pixel container width will be 300
otherwise, container height will be 100 pixel
as you can see on emulator when changing orientation container size changes
Thanks For Watching
