avoid_single_child_in_multi_child_widgets
v0.1.0 Warning Fix Widget Best Practices
This rule flags multi-child widgets like Column, Row, and Wrap that contain only a single child in their children list. A multi-child layout widget with one child adds unnecessary complexity and layout overhead for something that could be expressed more simply.
Why use this rule
Section titled “Why use this rule”A Column or Row with a single child does the same thing as just using that child directly, but adds an extra layout pass and makes the code harder to read. If you need alignment, use Align or Center. If you need padding, use Padding. Using the right widget for the job makes intent clearer and keeps the widget tree lean.
Scaffold( body: Column( // Column with a single child is unnecessary children: [Text('I am the only child')], ),)Scaffold( // Use the child widget directly body: Text('I am the only child'),)Configuration
Section titled “Configuration”To disable this rule:
plugins: many_lints: diagnostics: avoid_single_child_in_multi_child_widgets: false