i am searching a way for sizing a element in flutter with the dimensions of the parent widget. How can I do?
I tried with MediaQuery.of(WidgetParent)
but this not work.
Thanks
CodePudding user response:
If you want to size the current widget with respect to the parent widget's dimensions, check this Widget FractionallySizedBox
CodePudding user response:
The MediaQuery.of(context)
returns the device's screen size, not the parent widget.
You can get the size of the parent widget by using the LayoutBuilder
.
YOUTUBE: LayoutBuilder (Flutter Widget of the Week)
LayoutBuilder(
builder: (context, constraints) {
constraints.maxWidth;
...
}
);