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
}
}
✅ Good:
class _MyHomePageState<T> extends State<MyHomePage> {
int _counter = 0;
void initState() {
super.initState();
}
}