avoid-late-context
Warns when the context
is used inside a late
field.
Using the context in late fields might result in an unexpected behavior due to late fields being initialized lazily.
Example
❌ Bad:
class _SomeState extends State<T> {
// LINT: Avoid accessing 'context' in late field initializers. Try rewriting the initializer.
late final _myState = _create(context);
}
✅ Good:
class _SomeState extends State<T> {
late final _myState = _create();
}