I am using the following code to launch URLs from my app:
WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = false;
if (!kIsWeb && Platform.isIOS) {
// on ios, not doing this will result in a dark status bar appearance
// which makes the content nearly invisible due to the dark background
// https://github.com/flutter/flutter/issues/105139#issuecomment-1143954699
final bool isDarkMode = SchedulerBinding.instance.platformDispatcher.platformBrightness == Brightness.dark;
SystemChrome.setSystemUIOverlayStyle(isDarkMode ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark);
}
final Future<bool> result = launchUrl(uri);
// wait until user closes the browser
// https://github.com/flutter/flutter/issues/57536#issuecomment-931594792
do {
await Future<void>.delayed(const Duration(milliseconds: 100));
} while (WidgetsBinding.instance.lifecycleState != AppLifecycleState.resumed);
WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = true;
How can one achieve the same without WidgetsBinding.instance.renderView
since it’s deprecated?
According to the docs, one should use RendererBinding.renderViews
instead. But how can we find out the current RenderView
, and is there maybe a more elegant solution?