Answers for "dialog close event flutter"

3

flutter close dialog

showDialog(
    context: context,
    builder: (_) {
      return AlertDialog(
        title: Text('Wanna Exit?'),
        actions: [
          FlatButton(
            onPressed: () => Navigator.pop(context, false), // passing false
            child: Text('No'),
          ),
          FlatButton(
            onPressed: () => Navigator.pop(context, true), // passing true
            child: Text('Yes'),
          ),
        ],
      );
    }).then((exit) {
  if (exit == null) return;

  if (exit) {
    // user pressed Yes button
  } else {
    // user pressed No button
  }
});
Posted by: Guest on August-10-2020
0

flutter dialog prevent close

showDialog(
  barrierDismissible: false,
  builder: ...
)
Posted by: Guest on March-12-2021

Code answers related to "Dart"

Browse Popular Code Answers by Language