@@ -100,15 +100,36 @@ enum BottomNavigationBarLandscapeLayout {
100
100
///
101
101
/// ## Updating to [NavigationBar]
102
102
///
103
- /// There is an updated version of this component, [NavigationBar] ,
104
- /// that's preferred for new applications and applications that are
105
- /// configured for Material 3 (see [ThemeData.useMaterial3] ). The
106
- /// [NavigationBar] widget's visuals are a little bit different, see
107
- /// the Material 3 spec at
103
+ /// The [NavigationBar] widget's visuals
104
+ /// are a little bit different, see the Material 3 spec at
108
105
/// <https://m3.material.io/components/navigation-bar/overview> for
109
- /// more details. The API is similar, destinations are defined with
110
- /// [NavigationDestination] s and [NavigationBar.onDestinationSelected]
111
- /// is called when a destination is tapped.
106
+ /// more details.
107
+ ///
108
+ /// The [NavigationBar] widget's API is also slightly different.
109
+ /// To update from [BottomNavigationBar] to [NavigationBar] , you will
110
+ /// need to make the following changes.
111
+ ///
112
+ /// 1. Instead of using [BottomNavigationBar.items] , which
113
+ /// takes a list of [BottomNavigationBarItem] s, use
114
+ /// [NavigationBar.destinations] , which takes a list of widgets.
115
+ /// Usually, you use a list of [NavigationDestination] widgets.
116
+ /// Just like [BottomNavigationBarItem] s, [NavigationDestination] s
117
+ /// have a label and icon field.
118
+ ///
119
+ /// 2. Instead of using [BottomNavigationBar.onTap] ,
120
+ /// use [NavigationBar.onDestinationSelected] , which is also
121
+ /// a callback that is called when the user taps on a
122
+ /// navigation bar item.
123
+ ///
124
+ /// 3. Instead of using [BottomNavigationBar.currentIndex] ,
125
+ /// use [NavigationBar.selectedIndex] , which is also an integer
126
+ /// that represents the index of the selected destination.
127
+ ///
128
+ /// 4. You may also need to make changes to the styling of the
129
+ /// [NavigationBar] , see the properties in the [NavigationBar]
130
+ /// constructor for more details.
131
+ ///
132
+ /// ## Using [BottomNavigationBar]
112
133
///
113
134
/// {@tool dartpad}
114
135
/// This example shows a [BottomNavigationBar] as it is used within a [Scaffold]
@@ -122,6 +143,13 @@ enum BottomNavigationBarLandscapeLayout {
122
143
/// {@end-tool}
123
144
///
124
145
/// {@tool dartpad}
146
+ /// This example shows how you would migrate the above [BottomNavigationBar]
147
+ /// to the new [NavigationBar] .
148
+ ///
149
+ /// ** See code in examples/api/lib/material/navigation_bar/navigation_bar.0.dart **
150
+ /// {@end-tool}
151
+ ///
152
+ /// {@tool dartpad}
125
153
/// This example shows a [BottomNavigationBar] as it is used within a [Scaffold]
126
154
/// widget. The [BottomNavigationBar] has four [BottomNavigationBarItem]
127
155
/// widgets, which means it defaults to [BottomNavigationBarType.shifting] , and
0 commit comments