showMessage function

void showMessage(
  1. BuildContext context,
  2. String message, {
  3. bool useLight = true,
  4. void onOk()?,
})

show message dialog

Implementation

void showMessage(BuildContext context, String message,
    {bool useLight = true, void Function()? onOk}) {
  var dialog = (BuildContext ctx) => CupertinoAlertDialog(
        content: Center(
          child: Container(
            padding: EdgeInsets.all(10),
            child: Text(message),
          ),
        ),
        actions: [
          CupertinoDialogAction(
            child: Text("OK"),
            isDefaultAction: true,
            onPressed: () {
              Navigator.pop(ctx);
              if (onOk != null) onOk();
            },
          )
        ],
      );

  showCupertinoDialog(
    context: context,
    builder: (BuildContext ctx) => useLight
        ? Theme(
            data: ThemeData.light(),
            child: dialog(ctx),
          )
        : dialog(ctx),
  );
}