IndexedStack (Flutter Widget of the Week)
Why Stack Overflow recommends it
Stack Overflow users link it when answering Flutter questions about bottom navigation or tabs that lose state or redraw (like maps) every time the user switches screens.
Recommended by 1 people across 1 different months, 2020 to 2021.
What it is
A one-minute Flutter 'Widget of the Week' episode from the official Flutter channel explaining IndexedStack. It shows how the widget swaps between children without animation while keeping each child's state alive.
What people said
Recommends ABDERRAHMANE OUALI · 2021-04 · Stack Overflow · on “Need a persistent/same Bottom Navigation Bar for all screens - Flutter”
this works perfectly for my use case, you can look at the youtube video that explain how to use it Here [this video]
Cites Kohls · 2020-04 · Stack Overflow · on “Ontap is not working on Google Maps marker in flutter”
Replace child: _widgetOptions.elementAt(fd.indexForFeedback), With child: IndexedStack( children: _widgetOptions, index: fd.indexForFeedback, ), It prevents from redrawing the map every time you switch between tabs, and avoid memory leaks. See also: [this video]
Cites Amon C · 2020-10 · Stack Overflow · on “Page started at begin when navigate between 2 screen using BottomTabNavigator”
Consider using IndexedStack like this. It will save the state of the previous widget while moving to another. body: IndexedStack(.....), bottomNavigationBar: BottomNavigationBar( onTap: (index) => handleTapEvent(index), currentIndex: _curruntIndex, items: [ BottomNavigationBarItem( icon: Icon( Icons.home, ), title: Text('Home'), ), BottomNavigationBarItem( icon: Icon( Icons.notifications, ), title: Text('Notifications'), ), BottomNavigationBarItem( icon: Icon( Icons.lock, ), title: Text('Profile'), ) ], ), IndexedStack Widget Video [this video] Tutorial on medium [LINK]