title: Speech To Text Singleton Class in Flutter
body: <p>I am using this <a href="https://pub.dev/packages/speech_to_text" rel="nofollow noreferrer">library</a> for stt.</p>
  <p>it says that</p>
  <blockquote>
  <p>Initialize once</p>
  <p>The initialize method only needs to be called once per application
  session. After that listen, start, stop, and cancel can be used to
  interact with the plugin. Subsequent calls to initialize are ignored
  which is safe but does mean that the onStatus and onError callbacks
  cannot be reset after the first call to initialize. For that reason
  there should be only one instance of the plugin per application. The
  SpeechToTextProvider is one way to create a single instance and easily
  reuse it in multiple widgets.</p>
  </blockquote>
  <p>my code:</p>
  <pre><code>final SpeechToText speech = SpeechToText();
  SpeechToTextProvider? speechProvider;
  
  Future&lt;void&gt; initSpeechState() async {
      await speechProvider?.initialize();
    }
  
  @override
    void initState() {
      super.initState();
      speechProvider = SpeechToTextProvider(speech);
      initSpeechState();
  }
  </code></pre>
  <p>The problem is that i define this in my root state and it works good in ios and android but this initializing method ask permissions from app launch state in ios side. What i would like to do is it should ask permissions (recognition, microphone) in the speech to text screen. Can i define this provider in a singleton and call it whenever i need this provider? It should initialize only once for per appliciation session.</p>