Flutter error: No Firebase App ‘[DEFAULT]’ has been created

Last updated on November 19, 2020 A Goodman Loading... Post a comment

Problem

When working with Flutter and Firebase, you may fall into the following error:

No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()

Solution

The solution is quite simple. Everything you need to do is opening the main.dart file and change from this:

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

To this:

// Import the Firebase Core package
import 'package:firebase_core/firebase_core.dart';

// Add async/await and 2 lines of code to the main function
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

After that, completely restart your Flutter app and check the result.

Related Articles

guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x