From 5127e02e65d26462c9f1c076be8f19432c5357df Mon Sep 17 00:00:00 2001 From: "chenghuai.dtc" Date: Fri, 11 Mar 2022 15:01:13 +0800 Subject: [PATCH] fix: fix scroller not disposed when element disposed. --- kraken/lib/src/css/overflow.dart | 2 ++ kraken/lib/src/dom/element.dart | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/kraken/lib/src/css/overflow.dart b/kraken/lib/src/css/overflow.dart index aea384899e..a39eb6ee18 100644 --- a/kraken/lib/src/css/overflow.dart +++ b/kraken/lib/src/css/overflow.dart @@ -118,6 +118,8 @@ mixin ElementOverflowMixin on ElementBase { KrakenScrollable? _scrollableY; void disposeScrollable() { + _scrollableX?.position?.dispose(); + _scrollableY?.position?.dispose(); _scrollableX = null; _scrollableY = null; } diff --git a/kraken/lib/src/dom/element.dart b/kraken/lib/src/dom/element.dart index 58db734911..e568687f35 100644 --- a/kraken/lib/src/dom/element.dart +++ b/kraken/lib/src/dom/element.dart @@ -646,6 +646,9 @@ class Element extends Node disposeRenderObject(); } + // Should make sure Scrollable.position are disposed earlier than RenderBoxModel. + disposeScrollable(); + RenderBoxModel? _renderBoxModel = renderBoxModel; Element? _parentElement = parentElement; @@ -661,7 +664,6 @@ class Element extends Node renderStyle.detach(); style.dispose(); properties.clear(); - disposeScrollable(); super.dispose(); }