initialize method

Future<bool> initialize()

Initializes the provider and the contained SpeechToText instance.

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

Implementation

Future<bool> initialize() async {
  if (isAvailable) {
    return isAvailable;
  }
  var availableBefore = _speechToText.isAvailable;
  var available =
      await _speechToText.initialize(onStatus: _onStatus, onError: _onError);
  if (available) {
    _locales = [];
    _locales.addAll(await _speechToText.locales());
    _systemLocale = await _speechToText.systemLocale();
  }
  if (availableBefore != available) {
    notifyListeners();
  }
  return available;
}