I am calling initial method to load data from API using initState. But it is resulting me an error. Here is error:
Unhandled Exception: inheritFromWidgetOfExactT
an alternative is to put it inside PostFrameCallback which is between initState and Build so we can be sure that the initState is already finished.
PostFrameCallback
initState
Build
@override void initState() { WidgetsBinding.instance.addPostFrameCallback((_) => getData()); super.initState(); } getData() async { }