@@ -173,6 +173,32 @@ void main() {
173
173
expect (tester.getCenter (find.text ('Title' )).dx, 400.0 );
174
174
});
175
175
176
+ // Assert that two SystemUiOverlayStyle instances have the same values for
177
+ // status bar properties and that the first instance has no system navigation
178
+ // bar properties set.
179
+ void expectSameStatusBarStyle (SystemUiOverlayStyle style, SystemUiOverlayStyle expectedStyle) {
180
+ expect (style.statusBarColor, expectedStyle.statusBarColor);
181
+ expect (style.statusBarBrightness, expectedStyle.statusBarBrightness);
182
+ expect (style.statusBarIconBrightness, expectedStyle.statusBarIconBrightness);
183
+ expect (style.systemStatusBarContrastEnforced, expectedStyle.systemStatusBarContrastEnforced);
184
+ expect (style.systemNavigationBarColor, isNull);
185
+ expect (style.systemNavigationBarContrastEnforced, isNull);
186
+ expect (style.systemNavigationBarDividerColor, isNull);
187
+ expect (style.systemNavigationBarIconBrightness, isNull);
188
+ }
189
+
190
+ // Regression test for https://github.com/flutter/flutter/issues/119270
191
+ testWidgets ('System navigation bar properties are not overriden' , (WidgetTester tester) async {
192
+ await tester.pumpWidget (
193
+ const CupertinoApp (
194
+ home: CupertinoNavigationBar (
195
+ backgroundColor: Color (0xF0F9F9F9 ),
196
+ ),
197
+ ),
198
+ );
199
+ expectSameStatusBarStyle (SystemChrome .latestStyle! , SystemUiOverlayStyle .dark);
200
+ });
201
+
176
202
testWidgets ('Can specify custom brightness' , (WidgetTester tester) async {
177
203
await tester.pumpWidget (
178
204
const CupertinoApp (
@@ -182,11 +208,7 @@ void main() {
182
208
),
183
209
),
184
210
);
185
-
186
- final AnnotatedRegion <SystemUiOverlayStyle > region1 = tester.allWidgets
187
- .whereType <AnnotatedRegion <SystemUiOverlayStyle >>()
188
- .single;
189
- expect (region1.value, SystemUiOverlayStyle .light);
211
+ expectSameStatusBarStyle (SystemChrome .latestStyle! , SystemUiOverlayStyle .light);
190
212
191
213
await tester.pumpWidget (
192
214
const CupertinoApp (
@@ -196,11 +218,7 @@ void main() {
196
218
),
197
219
),
198
220
);
199
-
200
- final AnnotatedRegion <SystemUiOverlayStyle > region2 = tester.allWidgets
201
- .whereType <AnnotatedRegion <SystemUiOverlayStyle >>()
202
- .single;
203
- expect (region2.value, SystemUiOverlayStyle .dark);
221
+ expectSameStatusBarStyle (SystemChrome .latestStyle! , SystemUiOverlayStyle .dark);
204
222
205
223
await tester.pumpWidget (
206
224
const CupertinoApp (
@@ -215,11 +233,7 @@ void main() {
215
233
),
216
234
),
217
235
);
218
-
219
- final AnnotatedRegion <SystemUiOverlayStyle > region3 = tester.allWidgets
220
- .whereType <AnnotatedRegion <SystemUiOverlayStyle >>()
221
- .single;
222
- expect (region3.value, SystemUiOverlayStyle .light);
236
+ expectSameStatusBarStyle (SystemChrome .latestStyle! , SystemUiOverlayStyle .light);
223
237
224
238
await tester.pumpWidget (
225
239
const CupertinoApp (
@@ -234,11 +248,7 @@ void main() {
234
248
),
235
249
),
236
250
);
237
-
238
- final AnnotatedRegion <SystemUiOverlayStyle > region4 = tester.allWidgets
239
- .whereType <AnnotatedRegion <SystemUiOverlayStyle >>()
240
- .single;
241
- expect (region4.value, SystemUiOverlayStyle .dark);
251
+ expectSameStatusBarStyle (SystemChrome .latestStyle! , SystemUiOverlayStyle .dark);
242
252
});
243
253
244
254
testWidgets ('Padding works in RTL' , (WidgetTester tester) async {
@@ -1021,7 +1031,7 @@ void main() {
1021
1031
},
1022
1032
),
1023
1033
);
1024
- expect (SystemChrome .latestStyle, SystemUiOverlayStyle .light);
1034
+ expectSameStatusBarStyle (SystemChrome .latestStyle! , SystemUiOverlayStyle .light);
1025
1035
});
1026
1036
1027
1037
testWidgets ('NavBar draws a dark system bar for a light background' , (WidgetTester tester) async {
@@ -1041,7 +1051,7 @@ void main() {
1041
1051
},
1042
1052
),
1043
1053
);
1044
- expect (SystemChrome .latestStyle, SystemUiOverlayStyle .dark);
1054
+ expectSameStatusBarStyle (SystemChrome .latestStyle! , SystemUiOverlayStyle .dark);
1045
1055
});
1046
1056
1047
1057
testWidgets ('CupertinoNavigationBarBackButton shows an error when manually added outside a route' , (WidgetTester tester) async {
0 commit comments