playText static method

Future<void> playText(
  1. String text, {
  2. AlertSeverity severity = AlertSeverity.information,
})

Play the given text using TTS.

Parameters

  • text: The text to be synthesized and played.
  • severity: Optional severity used to select preferences (defaults to AlertSeverity.information).

Implementation

static Future<void> playText(
  String text, {
  AlertSeverity severity = AlertSeverity.information,
}) async {
  if (GemKitPlatform.instance.androidVersion > -1) {
    await GemKitPlatform.instance
        .getChannel(mapId: -1)
        .invokeMethod<String>(
          'callObjectMethod',
          jsonEncode(<String, dynamic>{
            'id': 0,
            'class': 'SoundService',
            'method': 'playText',
            'args': <String, dynamic>{'text': text, 'severity': severity.id},
          }),
        );
  } else {
    staticMethod(
      'SoundService',
      'playText',
      args: <String, dynamic>{'text': text, 'severity': severity.id},
    );
  }
}