handleMethodCall method
Implementation
Future<dynamic> handleMethodCall(MethodCall call) async {
if (!supported) return;
switch (call.method) {
case 'speak':
final text = call.arguments as String?;
if (awaitSpeakCompletion) {
_speechCompleter = Completer();
}
_speak(text);
if (awaitSpeakCompletion) {
return _speechCompleter?.future;
}
break;
case 'awaitSpeakCompletion':
awaitSpeakCompletion = (call.arguments as bool?) ?? false;
return 1;
case 'stop':
_stop();
return 1;
case 'pause':
_pause();
return 1;
case 'setLanguage':
final language = call.arguments as String;
_setLanguage(language);
return 1;
case 'getLanguages':
return _getLanguages();
case 'getVoices':
return getVoices();
case 'setVoice':
final tmpVoiceMap =
Map<String, String>.from(call.arguments as LinkedHashMap);
return _setVoice(tmpVoiceMap);
case 'setSpeechRate':
final rate = call.arguments as double;
_setRate(rate);
return 1;
case 'setVolume':
final volume = call.arguments as double;
_setVolume(volume);
return 1;
case 'setPitch':
final pitch = call.arguments as double;
_setPitch(pitch);
return 1;
case 'isLanguageAvailable':
final lang = call.arguments as String;
return _isLanguageAvailable(lang);
default:
throw PlatformException(
code: 'Unimplemented',
details: "The flutter_tts plugin for web doesn't implement "
"the method '${call.method}'");
}
}