sized_box_for_whitespace

Group: style

Maturity: stable

Linter v0.1.115

Since info is static, may be stale
flutter

View all Lint Rules

Using the Linter

Use SizedBox to add whitespace to a layout.

A Container is a heavier Widget than a SizedBox, and as bonus, SizedBox has a const constructor.

BAD:

Widget buildRow() {
  return Row(
    children: <Widget>[
      const MyLogo(),
      Container(width: 4),
      const Expanded(
        child: Text('...'),
      ),
    ],
  );
}

GOOD:

Widget buildRow() {
  return Row(
    children: const <Widget>[
      MyLogo(),
      SizedBox(width: 4),
      Expanded(
        child: Text('...'),
      ),
    ],
  );
}