showGeneralDialog click to close in flutter code example

Example 1: alertdialog flutter outside click disble

showDialog(
  barrierDismissible: false, // <-- this
  builder: ...
)

Example 2: show dialog close flutter

BuildContext dialogContext; // <<----
  showDialog(
    context: context, // <<----
    barrierDismissible: false,
    builder: (BuildContext context) {
      dialogContext = context;
      return Dialog(
        child: new Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            new CircularProgressIndicator(),
            new Text("Loading"),
          ],
        ),
      );
    },
  );

  await _longOperation();
  Navigator.pop(dialogContext); // <<----

Tags:

Dart Example