File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
navigation_and_routing/lib/src/screens Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,14 @@ class _BooksScreenState extends State<BooksScreen>
3131 ..addListener (_handleTabIndexChanged);
3232 }
3333
34+ @override
35+ void didUpdateWidget (covariant BooksScreen oldWidget) {
36+ super .didUpdateWidget (oldWidget);
37+ if (oldWidget.selectedIndex != widget.selectedIndex) {
38+ _tabController.index = widget.selectedIndex;
39+ }
40+ }
41+
3442 @override
3543 void dispose () {
3644 _tabController.removeListener (_handleTabIndexChanged);
@@ -39,7 +47,6 @@ class _BooksScreenState extends State<BooksScreen>
3947
4048 @override
4149 Widget build (BuildContext context) {
42- _tabController.index = widget.selectedIndex;
4350 return Scaffold (
4451 appBar: AppBar (
4552 title: const Text ('Books' ),
You can’t perform that action at this time.
0 commit comments