I have a Tabbar
with two tabs. The Tabbar
has its own Appbar
which is used by both tabs. How do I have the sort button run custom (set state) functions inside each tab's stateful widget? Alternatively, is it possible for each tab to have its own unique Appbar
? I am not sure what best approach is here.
Example method inside one of the tabs:
class _TabAState extends State<TabA> {
void sort() {
setState(() {
myList.sort((a, b) => b.dueDate.compareTo(a.dueDate));
});
}
...
Sort button:
IconButton(
icon: Icon(Icons.sort),
onPressed: () => DefaultTabController.of(context).index == 0
? TabA.sort() // Does not work
: TabB.sort(), // Does not work
),