I am writing an application in flutter that has 4 tabbed views, kinda like the stock android phone app or clock app. One of those views hash a floating action button that wh
You need to use AutomaticKeepAliveClientMixin over your stateful widget and implement override method called wantKeepAlive
class MyApp extends StatefulWidget {
@override
createState() => new MyAppState();
}
use AutomaticKeepAliveClientMixin with your class extending state and ov
class MyAppState extends State with AutomaticKeepAliveClientMixin{
//your existing code.....
@override
bool get wantKeepAlive => true; //by default it will be null, change it to true.
//your existing code......
}
on setting wantKeepAlive to true, initState method will run only once, at the time of creation.