prefer_align_over_container
v0.1.0 Warning Fix Widget Replacement
Flags Container widgets that only use the alignment parameter (plus optional key and child). When Container is used solely for alignment, the Align widget is a lighter, more descriptive alternative.
Why use this rule
Section titled “Why use this rule”Container is a convenience widget that composes many lower-level widgets internally. When you only need alignment, using Align directly avoids the overhead and makes the intent clearer. It also makes the widget tree easier to understand at a glance.
// Container with only alignment parameterContainer(alignment: Alignment.topLeft, child: Text('Hello'));
// Container with only alignment, no childContainer(alignment: Alignment.bottomRight);// Use Align directlyAlign(alignment: Alignment.topLeft, child: Text('Hello'));
Align(alignment: Alignment.bottomRight);Configuration
Section titled “Configuration”To disable this rule:
plugins: many_lints: diagnostics: prefer_align_over_container: false