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
Adding a frame callback might be better than using Future.delayed
with a zero duration - it's more explicit and clear as to what is happening, and this kind of situation is what frame callback was designed for:
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
_getCategories();
});
}