Skip to main content

avoid-redundant-async-on-load

added in: 1.6.0
🛠
Pro+

Warns when a Component's onLoad method can be made sync.

Refactoring async onLoad to sync helps Flame directly continue in it's loading cycle.

Example

❌ Bad:

class MyComponent extends Component {
Future<void> onLoad() async {
... // LINT, has no await
}
}

✅ Good:

class MyComponent extends Component {
Future<void> onLoad() async {
await ...
}
}

class MyComponent extends Component {
void onLoad() {
...
}
}