How to Solve No Firebase App Has Been Created??

· 3 min read
No Firebase App Has Been Created
No Firebase App Has Been Created

While Integrating Firebase you might have faced an error that says No Firebase App Has Been Created. Earlier We have been through Step By Step Guide to Integrate Firebase With Flutter.  Let’s go through how to deal with it.

How to Solve No Firebase App  Has Been Created – Call Firebase.initializeApp() in Flutter and Firebase ??

All Firebase versions have been updated and now you have to call Firebase.initializeApp() before using any Firebase product.

Firstly, all Firebase products now depend on firebase_core version 0.5.0+, therefore you need to add it in the pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter
  firebase_core : ^0.5.0
  # cloud_firestore: ^0.14.0

Then you have to call Firebase.initializeApp():

Import the firebase_core plugin like below:

import 'package:firebase_core/firebase_core.dart';

Now in an Initialize Firebase App like below:

import 'package:flutter/material.dart';

void main() {
  runApp(App());
}

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      // Initialize FlutterFire
      future: Firebase.initializeApp(),
      builder: (context, snapshot) {
        // Check for errors
        if (snapshot.hasError) {
          return SomethingWentWrong();
        }

        // Once complete, show your application
        if (snapshot.connectionState == ConnectionState.done) {
          return MyAwesomeApp();
        }

        // Otherwise, show something whilst waiting for initialization to complete
        return Loading();
      },
    );
  }
}

Initialize it in initState() then call setState() which will call the build() method.

@override
void initState() {
  super.initState();
  Firebase.initializeApp().whenComplete(() { 
    print("completed");
    setState(() {});
  });
}

Initialize it in the main() method after calling WidgetsFlutterBinding.ensureInitialized();

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

Note: You only have to call initializeApp() once.

So next up we will see: no firebase app ‘(default)’ has been created flutter,

no firebase app has been created flutter,

no firebase app has been created ios

and no firebase app flutter.

Conclusion:

So in this article, we have learned about How to Solve No Firebase App Has Been Created.

Thanks for Reading!!!
Keep Learning!!! 

Do let us know if you need any assistance with Flutter Development:)

FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

FlutterAgency.com is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

1 comment

Leave a Reply