Skip to content

Commit

Permalink
Feature: Showing flutter toast on creating or updating the alarm (#243)
Browse files Browse the repository at this point in the history
* adding the fluttertoast dependency

* showing the toast on creating or updating the alarm
  • Loading branch information
superiorsd10 authored Dec 17, 2023
1 parent 56f2641 commit 3014a85
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';
import 'package:fl_location/fl_location.dart';
import 'package:latlong2/latlong.dart';
Expand Down Expand Up @@ -259,6 +260,12 @@ class AddOrUpdateAlarmController extends GetxController {
} else {
alarmRecord = await IsarDb.addAlarm(alarmData);
}

Future.delayed(const Duration(seconds: 1), () {
showToast(
alarmRecord: alarmData,
);
});
}

showQRDialog() {
Expand Down Expand Up @@ -449,6 +456,12 @@ class AddOrUpdateAlarmController extends GetxController {
createAlarm(alarmData);
}
}

Future.delayed(const Duration(seconds: 1), () {
showToast(
alarmRecord: alarmData,
);
});
}

@override
Expand Down Expand Up @@ -786,4 +799,28 @@ class AddOrUpdateAlarmController extends GetxController {
debugPrint(e.toString());
}
}

void showToast({
required AlarmModel alarmRecord,
}) {
try {
String timeToAlarm = Utils.timeUntilAlarm(
Utils.stringToTimeOfDay(alarmRecord.alarmTime),
alarmRecord.days,
);

Fluttertoast.showToast(
msg: 'Rings in $timeToAlarm',
toastLength: Toast.LENGTH_LONG,
backgroundColor: themeController.isLightMode.value
? kLightSecondaryBackgroundColor
: ksecondaryBackgroundColor,
textColor: themeController.isLightMode.value
? kLightPrimaryTextColor
: kprimaryTextColor,
);
} catch (e) {
debugPrint(e.toString());
}
}
}
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies:
flutter:
sdk: flutter
flutter_native_splash: ^2.3.8
fluttertoast: ^8.2.4

dev_dependencies:
flutter_lints: ^2.0.3
Expand Down

0 comments on commit 3014a85

Please sign in to comment.