openAlertDialog method

void openAlertDialog(
  1. BuildContext context,
  2. String title,
  3. String message,
  4. String okMessage,
  5. String cancelMessage,
  6. dynamic confirm(
    1. bool,
    2. BuildContext
    ),
)

Implementation

void openAlertDialog(
    BuildContext context,
    String title,
    String message,
    String okMessage,
    String cancelMessage,
    final Function(bool, BuildContext) confirm) {
  showDialog<String>(
    context: context,
    builder: (BuildContext context) => AlertDialog(
      title: Text(title),
      content: Text(message),
      actions: <Widget>[
        TextButton(
          onPressed: () {
            confirm(false, context);
          },
          child: Text(cancelMessage),
        ),
        TextButton(
          onPressed: () {
            confirm(true, context);
          },
          child: Text(okMessage),
        ),
      ],
    ),
  );
}