@@ -84,10 +84,13 @@ Future<bool> launch(
8484 bool previousAutomaticSystemUiAdjustment = true ;
8585 if (statusBarBrightness != null &&
8686 defaultTargetPlatform == TargetPlatform .iOS &&
87- WidgetsBinding .instance != null ) {
88- previousAutomaticSystemUiAdjustment =
89- WidgetsBinding .instance! .renderView.automaticSystemUiAdjustment;
90- WidgetsBinding .instance! .renderView.automaticSystemUiAdjustment = false ;
87+ _ambiguate (WidgetsBinding .instance) != null ) {
88+ previousAutomaticSystemUiAdjustment = _ambiguate (WidgetsBinding .instance)!
89+ .renderView
90+ .automaticSystemUiAdjustment;
91+ _ambiguate (WidgetsBinding .instance)!
92+ .renderView
93+ .automaticSystemUiAdjustment = false ;
9194 SystemChrome .setSystemUIOverlayStyle (statusBarBrightness == Brightness .light
9295 ? SystemUiOverlayStyle .dark
9396 : SystemUiOverlayStyle .light);
@@ -104,9 +107,11 @@ Future<bool> launch(
104107 webOnlyWindowName: webOnlyWindowName,
105108 );
106109
107- if (statusBarBrightness != null && WidgetsBinding .instance != null ) {
108- WidgetsBinding .instance! .renderView.automaticSystemUiAdjustment =
109- previousAutomaticSystemUiAdjustment;
110+ if (statusBarBrightness != null &&
111+ _ambiguate (WidgetsBinding .instance) != null ) {
112+ _ambiguate (WidgetsBinding .instance)!
113+ .renderView
114+ .automaticSystemUiAdjustment = previousAutomaticSystemUiAdjustment;
110115 }
111116
112117 return result;
@@ -139,3 +144,10 @@ Future<bool> canLaunch(String urlString) async {
139144Future <void > closeWebView () async {
140145 return await UrlLauncherPlatform .instance.closeWebView ();
141146}
147+
148+ /// This allows a value of type T or T? to be treated as a value of type T?.
149+ ///
150+ /// We use this so that APIs that have become non-nullable can still be used
151+ /// with `!` and `?` on the stable branch.
152+ // TODO(ianh): Remove this once we roll stable in late 2021.
153+ T ? _ambiguate <T >(T ? value) => value;
0 commit comments