Dart Analyze

Dart Analyze

Community Analyzer

Avoid unnecessary containers DRT-W1072

Anti-pattern
Major

AVOID wrapping widgets in unnecessary containers.

Wrapping a widget in Container with no other parameters set has no effect and makes code needlessly more complex.

BAD:

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

GOOD:

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