Skip to main content

prefer-center-over-align

added in: 1.24.0
🛠
Pro+

Suggests using a 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();
}
}