Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel and Confirm #17

Closed
RobertBrunhage opened this issue Jun 19, 2018 · 6 comments
Closed

Cancel and Confirm #17

RobertBrunhage opened this issue Jun 19, 2018 · 6 comments
Labels

Comments

@RobertBrunhage
Copy link

RobertBrunhage commented Jun 19, 2018

How do I check if cancel and confirm?

I want to await the widget and if I press ok I want to keep doing the logic and if the user press cancel I want to stop the logic (with bool or something like that). But the cancel and confirm takes a widget. Why can I just not set logic in this?

I want to do something like this:

image

@MarcinusX
Copy link
Owner

Assuming you want to put in some sort of dialog, you can get the return value from that dialog. Having so, you can assume that if that value is null, user has canceled.

@RobertBrunhage
Copy link
Author

Right now I am using the _intervalPicker as a dialog in the app, and if I press ok I want to keep the method going and cancel if not.

Will the value be null when canceled or will it go back to the previous state?

@MarcinusX
Copy link
Owner

Take a look at this example from readme:

void _showDialog() {
    showDialog<int>(
      context: context,
      builder: (BuildContext context) {
        return new NumberPickerDialog.decimal(
          minValue: 1,
          maxValue: 10,
          title: new Text("Pick a new price"),
          initialDoubleValue: _currentPrice,
        );
      }
    );.then((int value)) {
      if (value != null) {
        setState(() => _currentPrice = value);
      }
    });
  }

If user closes dialog, then value is null.

@RobertBrunhage
Copy link
Author

Oh didn't know that, Thanks a lot for the help! :)

@MarcinusX
Copy link
Owner

Can I close it or you would like some more help? :)

@RobertBrunhage
Copy link
Author

You can close! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants