I have a very simple Flutter app with a TabBarView with two views (Tab 1 and Tab 2), one of them (Tab 1) has
Output:
Code:
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: Text("PageStorageKey"),
bottom: TabBar(
tabs: [
Tab(icon: Icon(Icons.looks_one), text: "List1"),
Tab(icon: Icon(Icons.looks_two), text: "List2"),
],
),
),
body: TabBarView(
children: [
_buildList(key: "key1", string: "List1: "),
_buildList(key: "key2", string: "List2: "),
],
),
),
);
}
Widget _buildList({String key, String string}) {
return ListView.builder(
key: PageStorageKey(key),
itemBuilder: (_, i) => ListTile(title: Text("${string} ${i}")),
);
}