title: Flutter Firebase storage instance appears uninitialized
body: <p>I'm writing a mobile application in Flutter and have encountered an issue relating to Firebase Storage. Part of the application needs to take an picture with the device's camera and upload it to a Firebase Storage bucket. </p>
  
  <p>The upload function was working until I added some authentication functionality among other small changes.</p>
  
  <p>Here is the issue:</p>
  
  <p>It appears that the Firebase storage instance is uninitialized. I have seen some examples showing that Firebase may be initialized with a function that takes the api key, bucket, and such as arguments. The google documentation never refers to this function, however, and it instead recommends to copy <code>GoogleService-Info.plist</code> and <code>google-services.json</code> into the project. I've done this, and it works. The authentication api and the Firestore api, both of which I am also using in the app, both work properly. It is just Firebase storage that is problematic.</p>
  
  <p>In my main function, for instance, I added the following code to show the problem.</p>
  
  <pre><code>Future&lt;void&gt; main() async{
  
      // setup camera
      WidgetsFlutterBinding.ensureInitialized();
      final cameras = await availableCameras();
  
      // look here!!
      print('firestore: ${Firestore.instance.app}');
      print('storage:   ${FirebaseStorage.instance.app}');
  
      runApp(MyApp(cameras: cameras));
  }
  </code></pre>
  
  <p>And upon running the app (on a physical device), this is the console output:</p>
  
  <pre><code>Restarted application in 1,097ms.
  flutter: firestore: FirebaseApp(__FIRAPP_DEFAULT)
  flutter: storage:   null
  </code></pre>
  
  <p>I am really stumped as to what might cause this partial failure of Firebase to initialize. I've tried changing the access rules in the Firebase console but this has no effect. Below I've pasted the section of my <code>pubspec.yaml</code> file having do do with Firebase includes.</p>
  
  <pre><code>  # Firebase
    firebase_core: ^0.4.0+9
    firebase_analytics: ^5.0.2
    firebase_auth: ^0.14.0+5
    cloud_firestore: ^0.12.9+5
    firebase_storage: ^3.0.8
  </code></pre>
  
  <p>Also, here is the code that makes the request to the Storage API. Again, I don't think this is the issue because the instance is null from the beginning, but here it is for the sake of completeness:</p>
  
  <pre><code>    // saves a locally stored image at local_uri as name. After the storage task
      // is complete, the DocumentReference ref is updated with the new url
      Future&lt;void&gt; _save_storage(String name, String local_uri, DocumentReference ref) async {
          StorageReference storage_reference;
  
          storage_reference = FirebaseStorage.instance.ref().child('images/$name');
  
          final StorageUploadTask upload_task = storage_reference.putFile(io.File(local_uri));
          final StorageTaskSnapshot download_url = (await upload_task.onComplete);
          final String url = (await download_url.ref.getDownloadURL());
  
          // now, update the file in the database to point to the correct storage
          // url
          Firestore.instance.runTransaction((transaction) async {
              await transaction.update(ref, {'image_url' : url});
          });
      }
  </code></pre>
  
  <p>Frustratingly, this issue throws no exceptions. Files are simply not uploaded to the bucket. I know that the instance fields are uninitialized by doing some random probing in debug mode. Also, I have found that the above StorageUploadTask instance has an error code of -13000, but I have not found any documentation on this error code anywhere.</p>
  
  <p>I am very new to both Flutter and Firebase, so I think part of the issue here is that I don't understand how Firebase instances are created. I would appreciate any guidance on this issue. Thank you.</p>