prefer_center_over_align
v0.1.0 Warning Fix Widget Replacement
Flags Align widgets that use Alignment.center (or omit the alignment parameter, which defaults to center). In these cases, the Center widget is a clearer and more idiomatic replacement.
Why use this rule
Section titled “Why use this rule”Center is a specialized subclass of Align that always aligns to center. Using Center makes the intent immediately obvious and removes the redundant alignment: Alignment.center argument. If you omit alignment on Align, Flutter defaults to center anyway — so you should just use Center.
// Align with explicit Alignment.centerAlign(alignment: Alignment.center, child: Text('Hello'));
// Align without alignment defaults to centerAlign(child: Text('World'));// Use Center directlyCenter(child: Text('Hello'));
Center(child: Text('World'));Configuration
Section titled “Configuration”To disable this rule:
plugins: many_lints: diagnostics: prefer_center_over_align: false