'Any way to delete alarms through flutter?

I am trying to create an app that will automatically set alarms based on a Google Sheets spreadsheet. I've managed to get it to set alarms, but after a few days, the alarms will start to stack up unless the user deletes them manually.

My question is if there's any way to delete a previous alarm before setting the next one, or maybe even better, if there's a way to delete an alarm once it goes off?

Any help is appreciated, thank you!

Code I used for initializing Flutter Alarm Clock -

  // TO Init GSheets
  final gsheets = GSheets(_credentials);

  // TO Fetch Spreadsheet by Id
  final spreadsheet = await gsheets.spreadsheet(_spreadsheetId);

  // TO Fetch Worksheet by Title
  var sheet = spreadsheet.worksheetByTitle("AlarmList");

  var alarmTime = await sheet!.values.value(column: 1, row: 5);
  log(alarmTime);

  var now = DateTime.now();
  var formatter = DateFormat('dd');
  String formattedDate = formatter.format(now);
  log(formattedDate); // 13

  // Column 1 = date
  // Column 2 = month
  // Column 3 = sehri h
  // Column 4 = sehri m
  // Column 5 = iftar h
  // Column 6 = iftar m

  globals.date = int.parse(formattedDate);
  globals.sehriHour =
      int.parse(await sheet.values.value(column: 3, row: globals.date));
  globals.sehriMinute =
      int.parse(await sheet.values.value(column: 4, row: globals.date));
  globals.iftarHour =
      int.parse(await sheet.values.value(column: 5, row: globals.date));
  globals.iftarMinute =
      int.parse(await sheet.values.value(column: 6, row: globals.date));

  log(globals.iftarHour.toString());

Global values stored in globals.dart -

library globals;

int date = 0;
int month = 0;
int sehriHour = 0;
int sehriMinute = 0;
int iftarHour = 0;
int iftarMinute = 0;

Code for setting alarm using Flutter Alarm Clock -

            ElevatedButton(
                onPressed: () {
                  FlutterAlarmClock.createAlarm(
                      globals.sehriHour, globals.sehriMinute - 5);
                },


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source