Unverified Commit 5c17a37b authored by Tomasz Gucio's avatar Tomasz Gucio Committed by GitHub

Dispose overlay entries (#132826)

parent 901a392a
......@@ -138,6 +138,7 @@ class _OverlayExampleState extends State<OverlayExample> {
// Remove the OverlayEntry.
void removeHighlightOverlay() {
overlayEntry?.remove();
overlayEntry?.dispose();
overlayEntry = null;
}
......
......@@ -572,6 +572,7 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
});
}
_lastOverlayEntry?.remove();
_lastOverlayEntry?.dispose();
_lastOverlayEntry = null;
case AnimationStatus.completed:
......@@ -585,6 +586,7 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
// one frame.
SchedulerBinding.instance.addPostFrameCallback((Duration _) {
_lastOverlayEntry?.remove();
_lastOverlayEntry?.dispose();
_lastOverlayEntry = null;
_openController.reset();
});
......
......@@ -484,10 +484,9 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
enableController.dispose();
startPositionController.dispose();
endPositionController.dispose();
if (overlayEntry != null) {
overlayEntry!.remove();
overlayEntry = null;
}
overlayEntry?.remove();
overlayEntry?.dispose();
overlayEntry = null;
super.dispose();
}
......@@ -842,8 +841,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
parent: _state.valueIndicatorController,
curve: Curves.fastOutSlowIn,
)..addStatusListener((AnimationStatus status) {
if (status == AnimationStatus.dismissed && _state.overlayEntry != null) {
_state.overlayEntry!.remove();
if (status == AnimationStatus.dismissed) {
_state.overlayEntry?.remove();
_state.overlayEntry?.dispose();
_state.overlayEntry = null;
}
});
......
......@@ -654,10 +654,9 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
valueIndicatorController.dispose();
enableController.dispose();
positionController.dispose();
if (overlayEntry != null) {
overlayEntry!.remove();
overlayEntry = null;
}
overlayEntry?.remove();
overlayEntry?.dispose();
overlayEntry = null;
_focusNode?.dispose();
super.dispose();
}
......@@ -1116,8 +1115,9 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
parent: _state.valueIndicatorController,
curve: Curves.fastOutSlowIn,
)..addStatusListener((AnimationStatus status) {
if (status == AnimationStatus.dismissed && _state.overlayEntry != null) {
_state.overlayEntry!.remove();
if (status == AnimationStatus.dismissed) {
_state.overlayEntry?.remove();
_state.overlayEntry?.dispose();
_state.overlayEntry = null;
}
});
......
......@@ -446,6 +446,7 @@ class _RawAutocompleteState<T extends Object> extends State<RawAutocomplete<T>>
}
_floatingOptions?.remove();
_floatingOptions?.dispose();
if (_shouldShowOptions) {
final OverlayEntry newFloatingOptions = OverlayEntry(
builder: (BuildContext context) {
......@@ -562,6 +563,7 @@ class _RawAutocompleteState<T extends Object> extends State<RawAutocomplete<T>>
_focusNode.dispose();
}
_floatingOptions?.remove();
_floatingOptions?.dispose();
_floatingOptions = null;
super.dispose();
}
......
......@@ -568,6 +568,7 @@ class _HeroFlight {
assert(overlayEntry != null);
overlayEntry!.remove();
overlayEntry!.dispose();
overlayEntry = null;
// We want to keep the hero underneath the current page hidden. If
// [AnimationStatus.completed], toHero will be the one on top and we keep
......
......@@ -242,9 +242,8 @@ class MagnifierController {
Widget? debugRequiredFor,
OverlayEntry? below,
}) async {
if (overlayEntry != null) {
overlayEntry!.remove();
}
_overlayEntry?.remove();
_overlayEntry?.dispose();
final OverlayState overlayState = Overlay.of(
context,
......@@ -257,7 +256,7 @@ class MagnifierController {
to: Navigator.maybeOf(context)?.context,
);
_overlayEntry = OverlayEntry(
_overlayEntry = OverlayEntry(
builder: (BuildContext context) => capturedThemes.wrap(builder(context)),
);
overlayState.insert(overlayEntry!, below: below);
......@@ -307,6 +306,7 @@ class MagnifierController {
@visibleForTesting
void removeFromOverlay() {
_overlayEntry?.remove();
_overlayEntry?.dispose();
_overlayEntry = null;
}
......
......@@ -832,6 +832,7 @@ class SliverReorderableListState extends State<SliverReorderableList> with Ticke
_recognizer?.dispose();
_recognizer = null;
_overlayEntry?.remove();
_overlayEntry?.dispose();
_overlayEntry = null;
_finalDropPosition = null;
}
......
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