showAlertDialog method

Future showAlertDialog (
  1. {String title,
  2. @required String message,
  3. dynamic closeButtonTitle: "OK"}
)

Show a simple dialog with title, message and a close button.

Example usage:

void _showUploadSuccessDialog(BuildContext context) {
  context.showDialog(
    message: "Uploaded successful!",
  );
}

Implementation

Future showAlertDialog({
  String title,
  @required String message,
  closeButtonTitle = "OK",
}) {
  return showDialog<void>(
    context: this,
    builder: (BuildContext context) {
      return AlertDialog(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(FludaX.x3),
        ),
        title: (title != null).ifTrue(
          Text(
            title ?? "",
            style: context.theme.textTheme.headline5,
          ),
        ),
        content: Text(
          message ?? "",
          style: context.theme.textTheme.headline6,
        ),
        actions: <Widget>[
          FlatButton(
            child: Text(
              closeButtonTitle,
              style: context.theme.textTheme.button,
            ),
            onPressed: () => this.navigator.pop(),
          ),
        ],
      );
    },
  );
}