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
Use the didChangeDependencies method which gets called after initState.
For your example:
@override void initState() { super.initState(); } @override void didChangeDependencies() { super.didChangeDependencies(); this._getCategories(); } void _getCategories() async { // Omitted for brevity // ... }