sh static method

dynamic sh(
  1. BuildContext context,
  2. Function fn
)

Implementation

static sh(BuildContext context, Function fn) async {
  return await showDialog(
    context: context,
    builder: (BuildContext context) {
      return AlertDialog(
        title: const Text("Confirm"),
        content: const Text("Are you sure you wish to delete this item?"),
        actions: <Widget>[
          ElevatedButton(
              onPressed: () {
                Navigator.of(context).pop(true);
                fn(true);
              },
              child: const Text("DELETE")),
          TextButton(
            onPressed: () {
              Navigator.of(context).pop(false);
              fn(false);
            },
            child: const Text("CANCEL"),
          ),
        ],
      );
    },
  );
}