showConfirmDialog static method

Future<void> showConfirmDialog(
  1. BuildContext context,
  2. String title,
  3. String message,
  4. void onOkPressed(),
)

Implementation

static Future<void> showConfirmDialog(
    BuildContext context, String title, String message, void Function() onOkPressed) async {
  return showDialog<void>(
    context: context,
    barrierDismissible: false, // user must tap button!
    builder: (BuildContext context) {
      return AlertDialog(
        title: Text(title),
        content: SingleChildScrollView(
          child: ListBody(
            children: <Widget>[
              Text(message),
            ],
          ),
        ),
        actions: <Widget>[
          TextButton(
            child: Text(tr('common.cancel')),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
          TextButton(
            child: Text(tr('common.ok')),
            onPressed: () {
              onOkPressed();
              Navigator.of(context).pop();
            },
          ),
        ],
      );
    },
  );
}