The method 'setState' isn't defined for the class MyApp error in Flutter
I assume you are trying to setState in a stateless widget, which is immutable(unable to change).
Use a stateful widget to do so, like this:
class MainPage extends StatefulWidget{
HomePage createState()=> HomePage();
}
class HomePage extends State<MainPage>{
//Your code here
}
place
setState
inside
StatefullWidget
:) that will solve the problem
You have to call that function within a stateful widget