title: How to fix the problem of 'Object of type XXXXX is not registered inside GetIt' in flutter?
body: <p>I am trying to use get_it in order to create a singleton object to be used. I do not wish to use multiple objects of API which is connecting to Firebase. The singleton object is that of Api call for firebase.</p>
  <p>I have used the following code</p>
  <pre><code>locator.registerLazySingleton&lt;Api&gt;(() =&gt; new Api('teams')) ;
  </code></pre>
  <p>while following code works</p>
  <pre><code>locator.registerLazySingleton&lt;TeamViewModel&gt;(() =&gt; new TeamViewModel()) ;
  </code></pre>
  <p>The structure of Api class is as follows:</p>
  <pre><code>class Api{
    final Firestore _db = Firestore.instance;
    final String path;
    CollectionReference ref;
    
    Api( this.path ) {
      ref = _db.collection(path);
    }
  
    Future&lt;QuerySnapshot&gt; getDataCollection() {
       return ref.getDocuments() ;
    }
  }`
  </code></pre>
  <p>This is how I use the API singleton object:</p>
  <pre><code>Api _api = locator&lt;Api&gt;();
  </code></pre>
  <p>while the following code works fine:</p>
  <pre><code>Api _api = Api('team');
  </code></pre>
  <p>I get the following error in console:</p>
  <blockquote>
  <p>I/flutter ( 2313): The following _Exception was thrown building MultiProvider:</p>
  <p>I/flutter ( 2313): Exception: Object of type Api is not registered inside GetIt</p>
  </blockquote>
  <p>I wish to know if this is even possible of using getit is not the right way to go about this.</p>