Skip to content

Commit

Permalink
Fix android fadeDuration cast error
Browse files Browse the repository at this point in the history
  • Loading branch information
gdelataillade committed Oct 3, 2023
1 parent 34afa06 commit 84c77b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
9 changes: 2 additions & 7 deletions lib/model/alarm_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ class AlarmSettings {
/// Path to audio asset to be used as the alarm ringtone. Accepted formats:
///
/// * Project asset: `assets/your_audio.mp3`.
///
/// * Local asset: `/path/to/your/audio.mp3`, which is your `File.path`.
///
/// For iOS, you need to drag and drop your asset(s) to your `Runner` folder
/// in Xcode and make sure 'Copy items if needed' is checked.
/// Check out README.md for more informations.
final String assetAudioPath;

/// If true, [assetAudioPath] will repeat indefinitely until alarm is stopped.
Expand Down Expand Up @@ -95,8 +90,8 @@ class AlarmSettings {
dateTime: DateTime.fromMicrosecondsSinceEpoch(json['dateTime'] as int),
assetAudioPath: json['assetAudioPath'] as String,
loopAudio: json['loopAudio'] as bool,
vibrate: json['vibrate'] != null ? json['vibrate'] as bool : true,
volumeMax: json['volumeMax'] != null ? json['volumeMax'] as bool : true,
vibrate: json['vibrate'] as bool,
volumeMax: json['volumeMax'] as bool,
fadeDuration: json['fadeDuration'] as double,
notificationTitle: json['notificationTitle'] as String?,
notificationBody: json['notificationBody'] as String?,
Expand Down
7 changes: 4 additions & 3 deletions lib/src/android_alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AndroidAlarm {
await playAlarm(id, {
"assetAudioPath": settings.assetAudioPath,
"loopAudio": settings.loopAudio,
"fadeDuration": settings.fadeDuration.toInt(),
"fadeDuration": settings.fadeDuration,
});
return true;
}
Expand Down Expand Up @@ -147,12 +147,13 @@ class AndroidAlarm {

send.send('vibrate-${audioDuration?.inSeconds}');

final loopAudio = data['loopAudio'];
final loopAudio = data['loopAudio'] as bool;
if (loopAudio) audioPlayer.setLoopMode(LoopMode.all);

send.send('Alarm data received in isolate: $data');

final fadeDuration = (data['fadeDuration'] as int).toDouble();
final fadeDuration = data['fadeDuration'];

send.send('Alarm fadeDuration: $fadeDuration seconds');

if (fadeDuration > 0.0) {
Expand Down

0 comments on commit 84c77b9

Please sign in to comment.