Skip to content

It's not always possible to know when a dialog is dismissed. #26542

@marcglasberg

Description

@marcglasberg

When a dialog is dismissed, it must be possible to run a callback.

Consider this code:

    Future<T> showDialog <T>({
        @required BuildContext context,
        bool barrierDismissible: true,
        WidgetBuilder builder
        })

There are 3 ways to close a dialog:
1) Pressing some button on the dialog that closes it.
2) Tapping the barrier.
3) Pressing the Android back button.

Currently only the first one allows us to fire a callback. That's very bad.

Please, create a onBarrierDismissed callback field, like this:

    Future<T> showDialog <T>({
        @required BuildContext context,
        bool barrierDismissible: true,
        VoidCallback: onBarrierDismissed, 
        WidgetBuilder builder
        })

Then pass it down to modal_barrier.dart, where instead of this:

    onTapDown: (TapDownDetails details) {
            if (dismissible) Navigator.maybePop(context);
          },

It should do this:

    onTapDown: (TapDownDetails details) {
            if (dismissible) {
                Navigator.maybePop(context);
                if (onBarrierDismissed != null) onBarrierDismissed();
             }
          },

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Fluttercustomer: crowdAffects or could affect many people, though not necessarily a specific customer.f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions