How to expand to Parent Widget width?

Jitesh Mohite
FlutterWorld
Published in
1 min readJul 29, 2020

This is always asked by the people, how to extend widget to its parent, so I thought of writing one blog which has all this.

The correct solution would be to use the SizedBox.expand widget, which enforces its child to match its parent's size.

SizedBox.expand(
child: RaisedButton(...),
)

Using SizeBox

SizedBox(
width: double.infinity,
// height: double.infinity,
child: RaisedButton(...),
)

Using ConstrainedBox

ConstrainedBox(
constraints: const BoxConstraints(minWidth: double.infinity),
child: RaisedButton(...),
)

Using Container

Containershould be used when we required other properties of it, otherwise, we should avoid and use SizeBox

Container(
width: double.infinity,
// height: double.infinity,
child: RaisedButton(...),
)

--

--

Jitesh Mohite
FlutterWorld

I am technology enthusiastic, want to learn things quickly and dive deep inside it. I always believe in developing logical things which makes impact on end user