I am new to flutter and when I want to call my context in InitState it throws an error :
which is about
BuildContext.inheritFromWidgetOfExactType
but then I use did
You cannot use
BuildContext.inheritFromWidgetOfExactTypefrom this method. However,didChangeDependencieswill be called immediately following this method, andBuildContext.inheritFromWidgetOfExactTypecan be used there.
So you need to use BuildContext.inheritFromWidgetOfExactType in didChangeDependencies.
context. That is why you have access to context outside build method. Regarding build(BuildContext context), build method accepts context from the parent widget. It means this parameter BuildContext context is not current widget's context but its parent's context.