deleteConfirmDialog method

void deleteConfirmDialog(
  1. BuildContext context
)

Implementation

void deleteConfirmDialog(BuildContext context) async {
  showDialog(
    context: context,
    barrierDismissible: true,
    builder: (BuildContext context) {
      return AlertDialog(
        title: Text("Delete Confirmation"),
        content: const Text("Are you sure want to delete all notifications ?"),
        actions: <Widget>[
          TextButton(
            child: const Text('CANCEL'),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
          TextButton(
            child: const Text('YES'),
            onPressed: () {
              if(items.isEmpty) return;
              db.deleteAll().then((val){
                initData();
                Navigator.of(context).pop();
                ScaffoldMessenger.of(_scaffoldCtx).showSnackBar(SnackBar(
                  content: Text("Notifications cleared!"),
                  duration: Duration(seconds: 3),
                ));
              });
            },
          )
        ],
      );
    },
  );
}