avoid-initializing-in-on-mount
added in: 1.0.0 warning.
Warns when a late final
variable is being initialized in the Component's onMount
method.
Since a Component might be removed and added again, attempt to reinitialize a late final variable will result in runtime exception.
Example
Bad:
class MyComponent extends Component {
late final int x;
@override
void onMount() {
x = 1; // LINT
}
}
Good:
class MyComponent extends Component {
int x;
@override
void onMount() {
x = 1;
}
}