@@ -112,6 +112,11 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
112112 /// and the hit-test result from the bottom of the screen provides the system
113113 /// nav bar settings.
114114 ///
115+ /// If there is no [AnnotatedRegionLayer] on the bottom, the hit-test result
116+ /// from the top provides the system nav bar settings. If there is no
117+ /// [AnnotatedRegionLayer] on the top, the hit-test result from the bottom
118+ /// provides the system status bar settings.
119+ ///
115120 /// Setting this to false does not cause previous automatic adjustments to be
116121 /// reset, nor does setting it to true cause the app to update immediately.
117122 ///
@@ -312,20 +317,47 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
312317 case TargetPlatform .windows:
313318 break ;
314319 }
315- // If there are no overlay styles in the UI don't bother updating.
316- if (upperOverlayStyle != null || lowerOverlayStyle != null ) {
320+ // If there are no overlay style in the UI don't bother updating.
321+ if (upperOverlayStyle == null && lowerOverlayStyle == null ) {
322+ return ;
323+ }
324+
325+ // If both are not null, the upper provides the status bar properties and the lower provides
326+ // the system navigation bar properties. This is done for advanced use cases where a widget
327+ // on the top (for instance an app bar) will create an annotated region to set the status bar
328+ // style and another widget on the bottom will create an annotated region to set the system
329+ // navigation bar style.
330+ if (upperOverlayStyle != null && lowerOverlayStyle != null ) {
317331 final SystemUiOverlayStyle overlayStyle = SystemUiOverlayStyle (
318- statusBarBrightness: upperOverlayStyle? .statusBarBrightness,
319- statusBarIconBrightness: upperOverlayStyle? .statusBarIconBrightness,
320- statusBarColor: upperOverlayStyle? .statusBarColor,
321- systemStatusBarContrastEnforced: upperOverlayStyle? .systemStatusBarContrastEnforced,
322- systemNavigationBarColor: lowerOverlayStyle? .systemNavigationBarColor,
323- systemNavigationBarDividerColor: lowerOverlayStyle? .systemNavigationBarDividerColor,
324- systemNavigationBarIconBrightness: lowerOverlayStyle? .systemNavigationBarIconBrightness,
325- systemNavigationBarContrastEnforced: lowerOverlayStyle? .systemNavigationBarContrastEnforced,
332+ statusBarBrightness: upperOverlayStyle.statusBarBrightness,
333+ statusBarIconBrightness: upperOverlayStyle.statusBarIconBrightness,
334+ statusBarColor: upperOverlayStyle.statusBarColor,
335+ systemStatusBarContrastEnforced: upperOverlayStyle.systemStatusBarContrastEnforced,
336+ systemNavigationBarColor: lowerOverlayStyle.systemNavigationBarColor,
337+ systemNavigationBarDividerColor: lowerOverlayStyle.systemNavigationBarDividerColor,
338+ systemNavigationBarIconBrightness: lowerOverlayStyle.systemNavigationBarIconBrightness,
339+ systemNavigationBarContrastEnforced: lowerOverlayStyle.systemNavigationBarContrastEnforced,
326340 );
327341 SystemChrome .setSystemUIOverlayStyle (overlayStyle);
342+ return ;
328343 }
344+ // If only one of the upper or the lower overlay style is not null, it provides all properties.
345+ // This is done for developer convenience as it allows setting both status bar style and
346+ // navigation bar style using only one annotated region layer (for instance the one
347+ // automatically created by an [AppBar]).
348+ final bool isAndroid = defaultTargetPlatform == TargetPlatform .android;
349+ final SystemUiOverlayStyle definedOverlayStyle = (upperOverlayStyle ?? lowerOverlayStyle)! ;
350+ final SystemUiOverlayStyle overlayStyle = SystemUiOverlayStyle (
351+ statusBarBrightness: definedOverlayStyle.statusBarBrightness,
352+ statusBarIconBrightness: definedOverlayStyle.statusBarIconBrightness,
353+ statusBarColor: definedOverlayStyle.statusBarColor,
354+ systemStatusBarContrastEnforced: definedOverlayStyle.systemStatusBarContrastEnforced,
355+ systemNavigationBarColor: isAndroid ? definedOverlayStyle.systemNavigationBarColor : null ,
356+ systemNavigationBarDividerColor: isAndroid ? definedOverlayStyle.systemNavigationBarDividerColor : null ,
357+ systemNavigationBarIconBrightness: isAndroid ? definedOverlayStyle.systemNavigationBarIconBrightness : null ,
358+ systemNavigationBarContrastEnforced: isAndroid ? definedOverlayStyle.systemNavigationBarContrastEnforced : null ,
359+ );
360+ SystemChrome .setSystemUIOverlayStyle (overlayStyle);
329361 }
330362
331363 @override
0 commit comments