Skip to content

Files

Latest commit

 

History

History
41 lines (34 loc) · 712 Bytes

avoid_unnecessary_containers.md

File metadata and controls

41 lines (34 loc) · 712 Bytes

Pattern: Use of unnecessary Container

Issue: -

Description

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

Example of incorrect code:

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

Example of correct code:

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

Further Reading