MethodChannelSoundEffect constructor
MethodChannelSoundEffect()
Implementation
MethodChannelSoundEffect() {
methodChannel.setMethodCallHandler((call) async {
switch (call.method) {
case 'onLoadComplete':
final soundId = call.arguments['soundId'];
final completer = _completers[soundId];
if (completer != null) {
if (!completer.isCompleted) {
completer.complete();
}
_completers.remove(soundId);
}
break;
case 'onLoadError':
final soundId = call.arguments['soundId'];
final completer = _completers[soundId];
if (completer != null) {
if (!completer.isCompleted) {
completer
.completeError(Exception('Failed to load sound $soundId'));
}
_completers.remove(soundId);
}
break;
default:
throw UnimplementedError('Method ${call.method} is not implemented');
}
});
}