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

后端 未结 9 1271
离开以前
离开以前 2020-11-22 15:32

I am building a flutter App and I have integrated Firebase but I keep getting this error when I click on a button either to register, login or logout. I have seen other peop

9条回答
  •  死守一世寂寞
    2020-11-22 15:49

    You need to add await Firebase.initializeApp(); which is a Future. Do it inside the dart file that is running your Firebase function like below:

    import 'package:firebase_core/firebase_core.dart';
    ...
    
    Future main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp();
      runApp(MaterialApp());
    }
    

提交回复
热议问题