Skip to content

Commit f3f2771

Browse files
蔡嘉健0xZOne
authored andcommitted
[ohos]解决透明弹窗返回时底下flutter页面闪烁的问题
1 parent a222e86 commit f3f2771

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
4. [ohos]适配最新的PlatformView方案
66
5. [ohos]解决横竖屏不生效的问题
77
6. [ohos]解决因权限问题从系统剪贴板获取数据失败的问题
8+
7. [ohos]解决透明弹窗返回时底下flutter页面闪烁的问题
89

910
# 4.5.10
1011
1. [dart]添加HDR/HEIC/HEIF/TIFF/WBMP/WEBP等图片格式的测试案例

ohos/src/main/ets/components/containers/FlutterBoostEntry.ets

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ export default class FlutterBoostEntry extends FlutterEntry implements FlutterVi
217217
private onContainerDestroy(): void {
218218
if (this.isTraceEnabled()) Log.d(TAG, "#onContainerDestroy: " + this.getUrl());
219219
this.detachFromEngineIfNeeded();
220-
FlutterBoost.getInstance().getPlugin()?.onContainerDestroyed(this);
221-
222-
// NavDestinationMode.DIALOG:
223-
// 默认透明,进出页面栈不影响下层NavDestination的生命周期,不支持系统转场动画。
224-
if (this.isDialogMode) {
225-
// try to attach previous container from the engine.
226-
const top = FlutterContainerManager.getInstance().getTopContainer();
227-
if (top && top != this) top.attachToEngineIfNeeded();
228-
}
220+
FlutterBoost.getInstance().getPlugin()?.onContainerDestroyed(this, () => {
221+
// NavDestinationMode.DIALOG:
222+
// 默认透明,进出页面栈不影响下层NavDestination的生命周期,不支持系统转场动画。
223+
if (this.isDialogMode) {
224+
// try to attach previous container from the engine.
225+
const top = FlutterContainerManager.getInstance().getTopContainer();
226+
if (top && top != this) top.attachToEngineIfNeeded();
227+
}
228+
});
229229
}
230230

231231
// super method override ===> start

ohos/src/main/ets/components/plugin/FlutterBoostPlugin.ets

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,16 @@ export class FlutterBoostPlugin implements FlutterPlugin, MethodCallHandler, Nat
316316
}
317317

318318
// 销毁 [4/4]
319-
public onContainerDestroyed(container: FlutterViewContainer) {
319+
public onContainerDestroyed(container: FlutterViewContainer, callback?: () => void) {
320320
let uniqueId = container.getUniqueId()
321321
if (this.isTraceEnabled()) Log.i(TAG, "## onContainerDestroyed: " + uniqueId);
322322
let args = container.getUrlParams()
323323
// 1.发送移除消息到dart侧
324-
this._sendRemoveRoute(uniqueId, args);
324+
this._sendRemoveRoute(uniqueId, args, () => {
325+
if (callback) {
326+
callback()
327+
}
328+
});
325329
// 2.移除FlutterContainerManager中的container
326330
FlutterContainerManager.getInstance().removeContainer(uniqueId);
327331
}
@@ -414,7 +418,7 @@ export class FlutterBoostPlugin implements FlutterPlugin, MethodCallHandler, Nat
414418
}
415419
}
416420

417-
private _sendRemoveRoute(uniqueId: string, args: Record<string, Object>) {
421+
private _sendRemoveRoute(uniqueId: string, args: Record<string, Object>, callback: () => void) {
418422
if (this.isTraceEnabled()) Log.i(TAG, "## _sendRemoveRoute: " + uniqueId);
419423
// 向flutter侧发送_sendRemoveRoute消息
420424
if (this.channel) {
@@ -423,6 +427,9 @@ export class FlutterBoostPlugin implements FlutterPlugin, MethodCallHandler, Nat
423427
params.uniqueId = uniqueId
424428
params.arguments = args
425429
this.channel.removeRoute(params, () => {
430+
if (callback) {
431+
callback()
432+
}
426433
});
427434
} else {
428435
throw new Error("FlutterBoostPlugin might *NOT* have attached to engine yet! When call _removeRoute");

0 commit comments

Comments
 (0)