Skip to content

Conversation

@bleroux
Copy link
Contributor

@bleroux bleroux commented Nov 7, 2025

Description

This PR adds an assert message to help users understand the error occuring when OverlayEntry.remove is called twice. It also adds a comment about calling dispose after removal as this is mandatory since github.com//issues/102794.

Related Issue

Fixes "Failed assertion: line 207 pos 12: '_overlay != null': is not true" when trying to remove a non null overlayEntry
Related external issue: LanarsInc/top-snackbar-flutter#80

Tests

  • Adds 1 test.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Nov 7, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the developer experience by adding a more descriptive assertion message when OverlayEntry.remove is called more than once. The accompanying documentation update and test case are well-implemented. I have one suggestion to make the new test more idiomatic.

@bleroux bleroux force-pushed the add_assert_message_for_OverlayEntry_remove branch from bfcb9e6 to 4577763 Compare November 7, 2025 17:28
///
/// This should only be called once.
///
/// After calling this method, [dispose] must be called if the [OverlayEntry] was
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true? You should be able to add the OverlayEntry to an Overlay right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this comment because of the one in dispose documentation:

/// This method must be called after [remove] if the [OverlayEntry] is
/// inserted into an [Overlay].

Probably I did not understand it properly and the one in dispose mean that 'dispose can only be call after remove' and not that dispose should always be call after remove?

Copy link
Contributor

@LongCatIsLooong LongCatIsLooong Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah iirc you can reuse an OverlayEntry after removing it from an Overlay, so it probably means "remove must be called before you can dispose it". Could you also rephrase that line so it's not ambiguous?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a commit which:

  • Rephrase ambiguous the comment in OverlayEntry.dispose
  • Remove the references to dispose in remove (references I added in my first commit based on my misunderstanding of the interaction between remove and dispose).

@bleroux bleroux force-pushed the add_assert_message_for_OverlayEntry_remove branch from 4577763 to 921101f Compare November 21, 2025 16:28
/// Discards any resources used by this [OverlayEntry].
///
/// This method must be called after [remove] if the [OverlayEntry] is
/// [remove] must be called before this method if the [OverlayEntry] is
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
/// [remove] must be called before this method if the [OverlayEntry] is
/// The [remove] method must be called before this method if the [OverlayEntry]

@bleroux bleroux force-pushed the add_assert_message_for_OverlayEntry_remove branch from 921101f to 54a53b2 Compare November 25, 2025 05:57
@bleroux bleroux added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Nov 25, 2025
Merged via the queue into flutter:master with commit 3460262 Nov 25, 2025
71 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2025
@bleroux bleroux deleted the add_assert_message_for_OverlayEntry_remove branch November 25, 2025 09:38
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 25, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 25, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 25, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 25, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 25, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 25, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 26, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 26, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 26, 2025
flutter/flutter@3f553f6...7b98d50

2025-11-26 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Fix for win32 embedder failing to send all alt key downs to the flutter app (#179097)" (flutter/flutter#179136)
2025-11-26 [email protected] Fix for win32 embedder failing to send all alt key downs to the flutter app (flutter/flutter#179097)
2025-11-26 [email protected] Modernize framework lints (flutter/flutter#179089)
2025-11-25 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Add framework-side hitTestBehavior support to Semantics (#178817)" (flutter/flutter#179100)
2025-11-25 [email protected] Add framework-side hitTestBehavior support to Semantics (flutter/flutter#178817)
2025-11-25 [email protected] Roll Packages from e019cf9 to cc3dca6 (1 revision) (flutter/flutter#179081)
2025-11-25 [email protected] Add tooltip windows to the windowing API alongside the window positioning logic (flutter/flutter#177404)
2025-11-25 [email protected] FlutterWindowsView::SendWindowMetrics now reliably sends the display_id (flutter/flutter#179053)
2025-11-25 [email protected] Remove semantics geometry shortcircuit (flutter/flutter#178680)
2025-11-25 [email protected] Add an assert message when OverlayEntry.remove is called twice (flutter/flutter#178163)
2025-11-25 [email protected] Roll Fuchsia Linux SDK from pOO9Jl9HTLsEmks6y... to nzuAxCJGeJbkZCTkr... (flutter/flutter#179066)
2025-11-25 [email protected] Dynamically set MinimumOSVersion in App.framework (flutter/flutter#178253)
2025-11-25 [email protected] Roll Skia from d83c30b090f4 to 925c311f4b37 (2 revisions) (flutter/flutter#179060)
2025-11-25 [email protected] Marks Linux build_android_host_app_with_module_aar to be unflaky (flutter/flutter#174864)
2025-11-25 [email protected] Marks Linux_mokey complex_layout__start_up to be unflaky (flutter/flutter#174865)
2025-11-25 [email protected] Manual Dart SDK roll to 3.11.0-169.0.dev (flutter/flutter#179054)
2025-11-25 [email protected] Bump Dart to 3.9 (flutter/flutter#179041)
2025-11-25 [email protected] Roll Skia from e298c2f93ebf to d83c30b090f4 (2 revisions) (flutter/flutter#179058)
2025-11-24 [email protected] updated licenses_cpp readme (flutter/flutter#178874)
2025-11-24 [email protected] Roll Skia from 43d2020be565 to e298c2f93ebf (5 revisions) (flutter/flutter#179046)
2025-11-24 [email protected] Refactor `_isLabel` method in `stepper.dart` to use `any` for better readablity (flutter/flutter#178909)
2025-11-24 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 5 to 6 in the all-github-actions group (flutter/flutter#179049)
2025-11-24 [email protected] Disposes test restoration manager when accessed by bindings (flutter/flutter#176519)
2025-11-24 [email protected] [ Widget Preview ] Always generate scaffold under `$TMP` (flutter/flutter#179039)
2025-11-24 [email protected] Roll Packages from e67b6be to e019cf9 (9 revisions) (flutter/flutter#179035)
2025-11-24 [email protected] Update CHANGELOG.md for Flutter 3.38.3 (flutter/flutter#178935)
2025-11-24 [email protected] Remove unnecessary `String.valueOf` in `SettingsChannel.java‎` (flutter/flutter#178590)
2025-11-24 [email protected] Roll pub manually, pick up flutter_lints in examples/api (flutter/flutter#179030)
2025-11-24 [email protected] Roll Dart SDK from 24cc9a740bd3 to afca43095efa (1 revision) (flutter/flutter#179019)
2025-11-24 [email protected] Pass EXCLUDED_ARCHS from Xcode project to xcodebuild for macOS builds (flutter/flutter#176948)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
…er#178163)

## Description

This PR adds an assert message to help users understand the error
occuring when `OverlayEntry.remove` is called twice. It also adds a
comment about calling dispose after removal as this is mandatory since
github.com/flutter/issues/102794.

## Related Issue

Fixes ["Failed assertion: line 207 pos 12: '_overlay != null': is not
true" when trying to remove a non null
overlayEntry](flutter#145466)
Related external issue:
LanarsInc/top-snackbar-flutter#80

## Tests

- Adds 1 test.
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…er#178163)

## Description

This PR adds an assert message to help users understand the error
occuring when `OverlayEntry.remove` is called twice. It also adds a
comment about calling dispose after removal as this is mandatory since
github.com/flutter/issues/102794.

## Related Issue

Fixes ["Failed assertion: line 207 pos 12: '_overlay != null': is not
true" when trying to remove a non null
overlayEntry](flutter#145466)
Related external issue:
LanarsInc/top-snackbar-flutter#80

## Tests

- Adds 1 test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Failed assertion: line 207 pos 12: '_overlay != null': is not true" when trying to remove a non null overlayEntry

2 participants