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(); }