Skip to main content

avoid-expanded-as-spacer

added in: 1.6.0
🛠
Free+

Suggests using the Spacer widget instead of the Expanded widget containing empty SizedBox/Container widget.

Example

❌ Bad:

Column(
children: [
Container(),
const Expanded(child: SizedBox()), // LINT: Prefer replacing this widget with the 'Spacer' widget.
Container(),
],
);

✅ Good:

Column(
children: [
Container(),
const Spacer(),
Container(),
],
);