Commit fa8ab3d0 authored by Jim's avatar Jim Committed by GitHub

Merge pull request #890 from GelaZhang/master

解决iOS启动第一次打开Flutter页面白屏
parents 570b0a69 0d521cc2
...@@ -71,7 +71,8 @@ class FlutterBoost { ...@@ -71,7 +71,8 @@ class FlutterBoost {
singleton.channel singleton.channel
.invokeMethod<Map<dynamic, dynamic>>('pageOnStart') .invokeMethod<Map<dynamic, dynamic>>('pageOnStart')
.then((Map<dynamic, dynamic> _pageInfo) { .then((Map<dynamic, dynamic> _pageInfo) {
final Map<String, dynamic> pageInfo = _pageInfo?.cast<String, dynamic>(); final Map<String, dynamic> pageInfo =
_pageInfo?.cast<String, dynamic>();
if (pageInfo?.isEmpty ?? true) { if (pageInfo?.isEmpty ?? true) {
return; return;
} }
...@@ -94,18 +95,11 @@ class FlutterBoost { ...@@ -94,18 +95,11 @@ class FlutterBoost {
PrePushRoute prePush, PrePushRoute prePush,
PostPushRoute postPush, PostPushRoute postPush,
}) { }) {
if (Platform.isAndroid) { // 1、methodChannel didShowPageContainer 在启动的时候可能不可靠,引擎刚启动method channel可能发不到dart
// 2、Flutter 1.22之后 rootIsolate启动是异步的, methodChannel didShowPageContainer 发到dart时可能main函数还没跑完,
// 此时flutter_boost还没初始化完成,路由切换失败,导致白屏。
// 所以需要boost启动后主动取一次路由信息
onPageStart(); onPageStart();
} else if (Platform.isIOS) {
// TODO(AlexVincent525): 未解之谜
assert(() {
() async {
onPageStart();
}();
return true;
}());
}
return (BuildContext context, Widget child) { return (BuildContext context, Widget child) {
assert(child is Navigator, 'child must be Navigator, what is wrong?'); assert(child is Navigator, 'child must be Navigator, what is wrong?');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment