showDeleteGroupDialog function

Future<void> showDeleteGroupDialog(
  1. BuildContext context,
  2. AtGroup group, {
  3. String? heading,
  4. Function? onDeleteSuccess,
})

Implementation

Future<void> showDeleteGroupDialog(
  BuildContext context,
  AtGroup group, {
  String? heading,
  Function? onDeleteSuccess,
}) async {
  return showDialog<void>(
    context: context,
    barrierDismissible: true,
    builder: (BuildContext context) {
      Uint8List? groupPicture;
      if (group.groupPicture != null) {
        List<int> intList = group.groupPicture.cast<int>();
        groupPicture = Uint8List.fromList(intList);
      }
      return ConfirmationDialog(
        title: '${group.displayName}',
        heading: heading ?? 'Are you sure you want to delete this group?',
        onYesPressed: () async {
          var result = await GroupService().deleteGroup(group);

          if (result is bool && result) {
            Navigator.of(context).pop();
            onDeleteSuccess?.call();
          } else {
            CustomToast().show(TextConstants().SERVICE_ERROR, context);
          }
        },
        image: groupPicture,
      );
    },
  );
}