12

I updated my Firebase packages to the latest version:

  firebase_auth: ^0.18.0+1
  cloud_firestore: "^0.14.0+2"
  firebase_core: "0.5.0"

I also added the following to my main function according to this post:

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

But when I leave the app to the main screen of the emulator and try to get back to the app I still get this error: [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()

It seems that the error was thrown building the landing page, so here it is:

class LandingPage extends StatelessWidget {
  
  @override
  Widget build(BuildContext context) {
    AuthService auth = Provider.of<AuthService>(context, listen: false);
    return StreamBuilder<UserCustom>(
      stream: auth.onAuthStatechanged,
      builder: (context, snapshot){
        if(snapshot.connectionState == ConnectionState.active){
          UserCustom user = snapshot.data;
          if(user == null){
            return SignInPage.create(context);
          }
          return JobsScreen();
        }else{
          return Scaffold(body: Center(child: CircularProgressIndicator(),));
        }
      },
    );
  }
}
  • Marked it as duplicate, on physical device example 4 is working fine. If you are using emulator and its not working then use example 2 – Peter Haddad Sep 01 '20 at 08:14

0 Answers0