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
There are many ways to solve this problem, override initState
method:
@override
void initState() {
super.initState();
// Use any of the below code here.
}
Using SchedulerBinding
mixin:
SchedulerBinding.instance.addPostFrameCallback((_) {
// Call your function
});
Using Future
class:
Future(() {
// Call your function
});
Using Timer
class:
Timer(() {
// Call your function
});