In case you want to keep the state of your screen in your TabBarView
, you can use the mixin class called AutomaticKeepAliveClientMixin
in your State class.
After that you have to override the wantKeepAlive
method and return true
. It will looks like something that :
class _SearchScreenState extends State<SearchScreen> with AutomaticKeepAliveClientMixin<SearchScreen>{
...
@override
Widget build(BuildContext context) {
// call this method
super.build(context);
/// your widget here
}
@override
bool get wantKeepAlive => true;
}
I wrote a post about that here: https://medium.com/@diegoveloper/flutter-persistent-tab-bars-a26220d322bc