File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -110,5 +110,40 @@ void main() {
110
110
final container = ProviderScope .containerOf (dashboard);
111
111
expect (container.read (navRailIndexStateProvider), 1 );
112
112
});
113
+
114
+ testWidgets ('Navigation Rail index should persist across widget rebuilds' ,
115
+ (tester) async {
116
+ // Pump the initial widget tree
117
+ await tester.pumpWidget (
118
+ const ProviderScope (
119
+ child: MaterialApp (
120
+ home: Dashboard (),
121
+ ),
122
+ ),
123
+ );
124
+
125
+ // Tap on the Settings icon to change the index to 2
126
+ await tester.tap (find.byIcon (Icons .settings_outlined));
127
+ await tester.pump (); // Wait for the animations to complete
128
+
129
+ // Rebuild the widget tree with the same ProviderScope
130
+ await tester.pumpWidget (
131
+ const ProviderScope (
132
+ child: MaterialApp (
133
+ home: Dashboard (),
134
+ ),
135
+ ),
136
+ );
137
+
138
+ // Verify that the navRailIndexStateProvider still has the updated value
139
+ final dashboard = tester.element (find.byType (Dashboard ));
140
+ final container = ProviderScope .containerOf (dashboard);
141
+ expect (container.read (navRailIndexStateProvider), 2 );
142
+
143
+ // Verify that the SettingsPage is still displayed after the rebuild
144
+ expect (find.byType (SettingsPage ), findsOneWidget);
145
+ expect (find.byType (IntroPage ), findsNothing);
146
+ expect (find.byType (HomePage ), findsNothing);
147
+ });
113
148
});
114
149
}
You can’t perform that action at this time.
0 commit comments