I have a TabBarView in my main.dart and every tab got a class to show the content(it's listview object), when i go between the tabs, the listview page refresh everytime, is it normal for tabbarview? I don't expect it will refresh everytime when i go between the tabs.
is it the problem my class? how to fix this? the code is something like this.
class ListWidget extends StatefulWidget {
final catID;
ListWidget(this.catID);
_ListWidgetState createState() => new _ListWidgetState(catID);
}
class _ListWidgetState extends State<ListWidget> {
var catID;
void initState() {
super.initState();
_fetchListData();
}
@override
Widget build(BuildContext context) {
// TODO: implement build
return new Scaffold(.......
}
MahMoos is right, however it's good to have an example here ...
`
class ListWidget extends StatefulWidget {
@override
_ListWidgetState createState() => _ListWidgetState();
}
class _ListWidgetState extends State<ListWidget> with
AutomaticKeepAliveClientMixin<ListWidget>{ // ** here
@override
Widget build(BuildContext context) {
super.build(context)
return Container();
}
@override
bool get wantKeepAlive => true; // ** and here
}