Open huangsir0 opened 6 months ago
I fixed this by moving WidgetsFlutterBinding.ensureInitialized()
to after the runWebViewTitleBarWidget
check.
The reason this happens is because runWebViewTitleBarWidget
run the titlebar widget in a guarded zone, which will be different than the one the widget binding is initialized in, if you initialize it before running the titlebar widget.
bool runWebViewTitleBarWidget(
List<String> args, {
WidgetBuilder? builder,
Color? backgroundColor,
void Function(Object error, StackTrace stack)? onError,
}) {
// ...
runZonedGuarded( // <-- this is what causes the problem
() {
WidgetsFlutterBinding.ensureInitialized();
runApp(_TitleBarApp(
// ...
));
},
onError ??
(e, s) {
debugPrint('WebViewTitleBar: unhandled expections: $e, $s');
},
);
return true;
}
A clear and concise description of what the bug is.
Reproduce Steps
Error log
**Version