Skip to main content

prefer-center-over-align

has auto-fix
pro+

Suggests using the Center widget instead of the Align widget with no passed arguments.

Example

❌ Bad:

class SomeWidget {
Widget build() {
// LINT: Prefer 'Center' over the 'Align' widget with 'Alignment.center'.
return Align();
}
}

✅ Good:

class SomeWidget {
Widget build() {
return Align(alignment: Alignment.left);
}
}

class SomeWidget {
Widget build() {
return Center();
}
}