Fix type null error (#647)

* fix: type null is not a subtype of double error

* chore: try/catch removed

* chore: fixed naming convention
This commit is contained in:
Osama Asif 2023-12-21 16:41:30 +05:00 committed by GitHub
parent 060b225957
commit 3acf683cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -173,13 +173,14 @@ class AudioPlayerNotifier extends BaseAudioHandler
) {
var isEnding = maxDuration.inSeconds > 0 &&
position.inSeconds > maxDuration.inSeconds - fadeDurationInSeconds;
if (isEnding) {
_setBgVolumeFadeAtEnd();
} else {
Future.delayed(Duration(milliseconds: 500), () {
setBackgroundSoundVolume(bgVolume);
});
if (bgVolume != null) {
Future.delayed(Duration(milliseconds: 500), () {
setBackgroundSoundVolume(bgVolume);
});
}
}
return isEnding;

View File

@ -29,6 +29,7 @@ final rootCombineProvider = Provider.family<void, BuildContext>((ref, context) {
void _handleAudioCompletion(Ref ref, BuildContext context) {
final audioProvider = ref.read(audioPlayerNotifierProvider);
final bgSoundProvider = ref.read(backgroundSoundsNotifierProvider);
var extras = audioProvider.mediaItem.value?.extras;
if (extras != null) {
ref.read(playerProvider.notifier).handleAudioCompletionEvent(
@ -38,7 +39,7 @@ void _handleAudioCompletion(Ref ref, BuildContext context) {
audioProvider.seekValueFromSlider(0);
audioProvider.pause();
audioProvider.setBackgroundSoundVolume(audioProvider.bgVolume);
audioProvider.setBackgroundSoundVolume(bgSoundProvider.volume);
audioProvider.stop();
ref.invalidate(packProvider);
WidgetsBinding.instance.addPostFrameCallback((_) {