avoid-inherited-widget-in-initstate
Warns when context.dependOnInheritedWidgetOfExactType
is transitively called from any invocation in initState
.
Example
❌ Bad:
class _MyHomePageState<T> extends State<MyHomePage> {
int _counter = 0;
void initState() {
super.initState();
Theme.of(context); // LINT: Avoid 'dependOnInheritedWidgetOfExactType' subscriptions in 'initState'.
}
}
✅ Good:
class _MyHomePageState<T> extends State<MyHomePage> {
int _counter = 0;
void initState() {
super.initState();
}
}