Flutter: Fatal Error: Callback lookup failed! (with audioplayers package)
I faced the same issue, so this works for my game code, I hope this works for you, first, create a Controller Class like this:
import 'package:audioplayers/audio_cache.dart';
import 'package:audioplayers/audioplayers.dart';
void audioPlayerHandler(AudioPlayerState value) => print('state => $value');
class GameController {
static AudioPlayer audioPlayer = AudioPlayer();
static AudioCache audioCache = AudioCache();
static void play(String sound) {
if (!kIsWeb && Platform.isIOS) {
audioPlayer.monitorNotificationStateChanges(audioPlayerHandler);
}
audioCache.play(sound);
}
}
Then use your code by this way:
FlatButton(
onPressed: () => {
GameController.play('note1.wav');
}
child: Text('Click to ding!'),
),