initialize method

Future<bool> initialize({
  1. dynamic debugLogging = false,
  2. Duration finalTimeout = SpeechToText.defaultFinalTimeout,
  3. List<SpeechConfigOption>? options,
})

Initializes the provider and the contained SpeechToText instance.

Returns true if SpeechToText was initialized successful and can now be used, false otherwise.

Implementation

Future<bool> initialize(
    {debugLogging = false,
    Duration finalTimeout = SpeechToText.defaultFinalTimeout,
    List<SpeechConfigOption>? options}) async {
  if (isAvailable) {
    return isAvailable;
  }
  var availableBefore = _speechToText.isAvailable;
  var available = await _speechToText.initialize(
      onStatus: _onStatus,
      onError: _onError,
      debugLogging: debugLogging,
      finalTimeout: finalTimeout,
      options: options);
  if (available) {
    _locales = [];
    _locales.addAll(await _speechToText.locales());
    _systemLocale = await _speechToText.systemLocale();
  }
  if (availableBefore != available) {
    notifyListeners();
  }
  return available;
}