Skip to content

Native sheet/dialog dismissal via gesture or scrim tap does not complete Future or notify PopScope #32

Closed

Description

@definev

Select your plan

Standard - priority support

Confirmations

  • I searched the existing feature requests and this is not a duplicate.

Framework or plugin?

Framework

Platform

Both

Use case

Problem

When dismissing a native sheet or dialog interactively (dragging down the grabber/detent or tapping the backdrop scrim), Dart is not notified:

  • The Future returned by showModalSheet / showModalBottomSheet / showDialog never completes.
  • PopScope.onPopInvokedWithResult is not triggered.

Programmatic Navigator.pop(context) works, but gesture/scrim dismissal leaves the Dart Future hanging, making it impossible for routers or state management to detect that the modal was closed.

Reproduction

https://github.com/definev/sheet_dismiss_repro. You can check the reproduction repo.

final future = showModalSheet(
  context: context,
  builder: (context) => PopScope(
    onPopInvokedWithResult: (didPop, result) => print('PopScope didPop: $didPop'),
    child: const Text('Sheet Content'),
  ),
);

future.then((value) => print('Future completed: $value'));

Proposal

Any of the following would solve the issue:

  1. Native dismissal callbacks on presentation primitives:
    Add an explicit callback or hook, e.g.:
    showModalSheet<T>({
      ...
      VoidCallback? onDismissed,
    });
  2. Expose transition/dismissal life-cycle via a Controller:
    Allow passing a controller (e.g. SheetController or NativePresentationHandle) that emits dismiss and completion events.
  3. Align with Flutter's modal route lifecycle:
    Ensure native presentation wrappers hook into the native UIAdaptivePresentationControllerDelegate (iOS) / OnBackPressedDispatcher or bottom sheet dialog callbacks (Android) to complete the bridge Completer on dismiss.

Activity

  1. added
    feature
    triage
    on Sep 17, 2026
  2. mikijg commented on Sep 17, 2026

    @mikijg
    Contributor

    Thanks for the detailed write-up!

    On PopScope you are right, and we can confirm it. PopScope is honoured on
    route pops, but an interactive dismissal completes the result and tears
    the presentation down without consulting the active PopScope entries, so
    onPopInvokedWithResult never runs for a swipe or scrim tap. We will fix it.

    On the Future we read the code differently, so we want to be sure before
    we change anything. All three functions install a native dismissal
    callback that completes the Future with null: on iOS through the system's
    dismissal delegate for a page sheet and the overlay's own tap and pan
    handling for the bottom sheet, on Android through the sheet's and the
    dialog's dismiss listeners. So a gesture or scrim dismissal should
    already complete it on both platforms.

    Have you seen it hang in a running app, or is this from reading the API?
    If you have seen it, please share a small repository that reproduces it,
    with a log from the failing run, plus your DartNative version and how you
    dismissed the sheet. The dismissal path prints a line under the dartnative
    name beginning "[DN-Dart] onDismissed fired": if it is missing when you
    dismiss, the problem is below Dart, and if it is there while your Future
    is pending, the problem is above it.

    Of your three proposals we would take the third. Hooking the native
    presentation into the route lifecycle fixes PopScope and anything else
    that depends on the route contract, instead of adding a parallel callback
    to each function.

  3. definev commented on Sep 17, 2026

    @definev
    Author

    I'm implementing routing library for dartnative and i want unify sheet with normal page. The problem is sheet doesn't have reliable way to notify router that they're dismissed. :-)

  4. definev commented on Sep 18, 2026

    @definev
    Author

    @mikijg I've added the reproduction repo in the issue. You can check by three step:

    • Open sheet then the text above the sheet: "Waiting for dismissal..."
    • Click the "Close Programmatically" -> the message changed to "Future completed: button"
    • Open sheet again
    • Drag to dissmiss. The status text still "Waiting for dismissal..."

    It's only happen in ios, android works fine

  5. mikijg commented on Sep 18, 2026

    @mikijg
    Contributor

    Thank you! We’ll look into this soon and plan to fix it in the next framework release, coming next week.

  6. definev commented on Sep 20, 2026

    @definev
    Author

    I'm implementing routing library for dartnative and i want unify sheet with normal page. The problem is sheet doesn't have reliable way to notify router that they're dismissed. :-)

    Have you (anyone) tried making a custom implementation on top of kaisel_core to handle this kind of routing logic?

    I'm the author of zenrouter so i prepared zenrouter_core as an infrastructure for zenrouter_dartnative. I want to make sure the routing experience will smooth as much as possible. Kaisel is a great one too. It's learned from zenrouter and using fairly different style to construct route. Zenrouter 3.0 also support that kind of style too so you will have best of both world :-)

  7. mikijg commented on Sep 22, 2026

    @mikijg
    Contributor

    We’re coding, and we’ll try to integrate this feature request as well. We may reach out to you on X for quick communication if needed.

    Thank you for helping make DN great!

  8. mikijg commented on Sep 23, 2026

    @mikijg
    Contributor

    Thank you! This is integrated and will be available in the upcoming framework release. We’ll close this once the new release is published.

    We took your third proposal. A PopScope inside showModalSheet, showModalBottomSheet or showDialog now follows the modal route contract on both platforms: canPop: false keeps the presentation up against the swipe, the tap outside and the system back, and onPopInvokedWithResult hears every attempt (didPop false) and every close (didPop true, with the result passed to Navigator.pop), before the Future completes. Your router can rely on either the callback or the Future.

  9. definev commented on Sep 23, 2026

    @definev
    Author

    Thank you :-) It's a great news 💙

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featuretriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions