alibaba / alibaba/flutter_boost

Android端 Fragment 包含的 Flutter 页面 首次启动 没有初始化 白屏或黑屏

Open
#1,483 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
7.2k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description


Android端 Fragment 包含的 Flutter 页面 首次启动 没有初始化 白屏或黑屏

App是登录后展示4个Tab。4个Tab是原生写的 tab里面嵌的是 Fragment , Fragment里面放的Flutter页面

mHomeFragment = new CunwFlutterFragment
.CachedEngineFragmentBuilder(CunwFlutterFragment.class)
.url("/home")
.build();

mClasssFragment = new ClasssFlutterFragment
.CachedEngineFragmentBuilder(ClasssFlutterFragment.class)
.url("/classs")
.build();

升级 flutter_boost 从 v3.0-preview.5. 到 v3.0-null-safety-preview.13 支持空安全版本后
Android端出现此问题
IOS端没有问题

日志
2021-11-25 10:36:30.121 29743-29999/cn.com.cunw.teacheraide I/flutter: ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞══════════════════════
The following _CastError was thrown during a scheduler callback:
Null check operator used on a null value

When the exception was thrown, this was the stack:
#0 BoostChannel.addEventListener (package:flutter_boost/boost_channel.dart:42:21)
#1 FlutterBoostAppState._addAppLifecycleStateEventListener (package:flutter_boost/flutter_boost_app.dart:125:10)
#2 FlutterBoostAppState.initState. (package:flutter_boost/flutter_boost_app.dart:102:7)
#3 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1143:15)
#4 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1088:9)
#5 SchedulerBinding.scheduleWarmUpFrame. (package:flutter/src/scheduler/binding.dart:863:7)
(elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
════════

overlayKey.currentContext 为null

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the first launch on Android with Flutter pages embedded in native Fragments after upgrading flutter_boost, then inspect the reported stack frames in package:flutter_boost/boost_channel.dart and package:flutter_boost/flutter_boost_app.dart. Use the overlayKey.currentContext null log to trace initialization timing. Done means the first launch initializes normally without a white or black screen or the reported null-check exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.