A bottom navigation bar is one of the most common UI patterns in mobile apps, but a static one can feel dull. Animating it adds polish and guides the user's attention. In Flutter, you can build a custom animated bar without third-party packages, using only core widgets like AnimatedContainer, AnimatedSwitcher, and Transform.
This article shows a practical implementation that you can drop into a real app. We'll cover state management, animation timing, performance, and common pitfalls. By the end, you'll have a bottom bar that smoothly highlights the selected tab and swaps icons with a satisfying transition.
Key points
- Use built-in implicit animations like AnimatedContainer and AnimatedSwitcher for most bottom bar effects.
- Keep animation durations between 150–300 ms for responsiveness.
- Always assign unique keys to AnimatedSwitcher children to trigger animations.
- Test performance on low-end devices and use the Flutter performance overlay.
Why Animate the Bottom Navigation Bar?
Animation isn't just eye candy. A subtle scale or color fade on the selected item gives users immediate feedback and reduces perceived latency. In usability tests, animated transitions of 200–300 ms are typically perceived as responsive without feeling sluggish. Google's Material Design guidelines recommend durations between 150 ms and 400 ms for most UI transitions.
Beyond feedback, animation can help users understand the relationship between tabs and content. For example, sliding an indicator under the active tab makes the current location obvious. It also makes the app feel more polished and modern, which matters for retention and store ratings.
- Provides clear visual feedback for tab selection
- Guides attention and reduces cognitive load
- Makes the app feel more responsive and modern
- Can be implemented with built-in Flutter widgets, no packages needed
Setting Up the Basic Bottom Navigation
Start with a Scaffold that contains a BottomNavigationBar or a custom Row of icons. For full control over animation, I prefer building a custom bar using a Row inside a Container with a fixed height of about 56–64 logical pixels. This gives you the flexibility to animate each item individually.
Define an enum or list for your destinations, and keep the selected index in a StatefulWidget's state. If you're new to the difference between widget types, see StatelessWidget vs StatefulWidget: Which One Should You Pick?. For a simple bar, a StatefulWidget is sufficient; for more complex apps, you might lift the state up or use a state management solution.
- Use a Row of custom items instead of BottomNavigationBar for full control
- Store the selected index in a StatefulWidget
- Keep the bar height consistent (56–64 dp)
- Consider lifting state if multiple screens need access
Animating the Selected Item
For each item, wrap the icon in an AnimatedContainer that changes size and color based on whether it's selected. A typical effect is to scale the active icon to 1.2x and change its color to your primary brand color. Use a duration of 200 ms and Curves.easeInOut for a natural feel.
You can also animate a small indicator bar under the active item. Use an AnimatedPositioned or an AnimatedAlign inside a Stack to slide the indicator horizontally. The width of the indicator should match the item width, which you can calculate by dividing the screen width by the number of items.
- Use AnimatedContainer for size and color changes
- Set duration to 200–300 ms with Curves.easeInOut
- Animate an indicator with AnimatedPositioned or AnimatedAlign
- Calculate item width as screenWidth / itemCount
| Approach | Typical Duration (ms) | Performance Impact | Ease of Implementation | Best For |
|---|---|---|---|---|
| AnimatedContainer | 200–300 | Low | Easy | Size and color changes |
| AnimatedSwitcher | 150–200 | Low | Easy | Icon swaps |
| AnimatedPositioned | 250–350 | Medium | Moderate | Sliding indicators |
| Explicit AnimationController | Variable | Medium–High | Hard | Complex, custom sequences |
| PageView + sync | 300–400 | Medium | Moderate | Swipeable tabs |
Swapping Icons with AnimatedSwitcher
Often you want to switch between outlined and filled versions of an icon when a tab is selected. AnimatedSwitcher makes this easy by cross-fading between the old and new child. Wrap the icon in an AnimatedSwitcher with a duration of 150–200 ms and a ScaleTransition or FadeTransition.
Make sure to give each icon a unique key (e.g., ValueKey(selected)) so AnimatedSwitcher knows to animate. This small detail prevents the switcher from treating both icons as the same widget and skipping the animation.
- Use AnimatedSwitcher to cross-fade between outlined and filled icons
- Duration: 150–200 ms
- Assign a unique key to each icon to trigger the switch
- Combine with a subtle scale for a polished effect
Performance Considerations
Animations should run at 60 fps (or 120 fps on high-refresh displays). To achieve that, avoid rebuilding the entire bar on every frame. Instead, use AnimatedContainer and other implicit animations that only rebuild the animated parts. If you're using an explicit AnimationController, make sure to dispose it properly.
Keep the widget tree shallow. A bottom bar with 5 items shouldn't have deeply nested widgets. Also, avoid using Opacity widgets for fading; prefer AnimatedOpacity or FadeTransition which are more efficient. For lists inside tabs, refer to Scrolling Widgets Compared: ListView, GridView and CustomScrollView to keep scrolling smooth.
- Target 60 fps; use the Flutter performance overlay to check
- Prefer implicit animations (AnimatedContainer) over manual controllers
- Dispose AnimationControllers to prevent memory leaks
- Keep the widget tree shallow for the bar
Handling State and Navigation
The bottom bar should update the selected index and also switch the body content. Use an IndexedStack to preserve the state of each tab, or a PageView if you want swipe gestures. IndexedStack keeps all tabs alive, which is great for performance if you have a few tabs, but can use more memory.
If you're using a PageView, sync the page changes with the bar selection. Listen to the PageController and update the selected index; also animate the bar when the page changes. This creates a cohesive experience.
- Use IndexedStack to preserve tab state
- Use PageView for swipeable tabs
- Sync bar selection with page changes
- Consider memory usage with many tabs
Common Pitfalls and How to Avoid Them
One common mistake is forgetting to set a unique key on animated widgets, causing them not to animate. Another is using too many animations at once, which can overwhelm the user. Stick to one or two animated properties per item.
Also, test on low-end devices. Animations that look smooth on a flagship might stutter on older hardware. Keep durations slightly longer (250–300 ms) if needed, and avoid complex curves. Finally, ensure the bar is accessible: use Semantics widgets to label each item for screen readers.
- Use unique keys for AnimatedSwitcher children
- Limit animations to essential properties
- Test on low-end devices and adjust durations
- Add Semantics labels for accessibility
Editor and Flutter contributor. Writes practical Flutter tutorials focused on widgets, layout and animation. Enjoys breaking large UI problems into small, testable pieces and explaining them clearly to beginners.



