What is the difference between Expanded and Flexible widgets?

Technology CommunityCategory: FlutterWhat is the difference between Expanded and Flexible widgets?
VietMX Staff asked 3 years ago

Expanded is just a shorthand for Flexible

Using expanded this way:

Expanded(
	child: Foo(),
);

is strictly equivalent to:

Flexible(
	fit: FlexFit.tight,
	child: Foo(),
);

You may want to use Flexible over Expanded when you want a different fit, useful in some responsive layouts.

The difference between FlexFit.tight and FlexFit.loose is that loose will allow its child to have a maximum size while tight forces that child to fill all the available space.