flutter firebase MissingPluginException

Viewed 3294

I just added firebase to my flutter App, i followed all the steps correctly, but i'm getting an error when initializing the app

this is my code to initialize app

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: new ThemeData(
        canvasColor: Colors.white,
      ),
      home: PersistentTabsDemo(),
      onGenerateRoute: route.controller,
    );
  }
}

this are the dependecies i added to pubsec.yaml

  firebase_core: ^1.6.0
  firebase_analytics: ^8.3.1
  firebase_auth: ^3.1.0
  cloud_firestore: ^2.5.1

and this is the error

Error: MissingPluginException(No implementation found for method Firebase#initializeCore on channel
plugins.flutter.io/firebase_core)

Edit: i tried removing async and await from my main class now i'm getting new error

No firebase App 'default' has been created - call Firebase.intializeApp() 
2 Answers

Try Flutter clean Pub.get If these two doesn't work Something is missing in setup of Firebase flutter

If anyone else had the same issue as me

I've fixed the issue by creating another project and added the sh1 and sh256 to firebase just follow this tuto it's really helpful https://www.youtube.com/watch?v=CpyALC8Zpxo

PS: when u add firebase to your flutter project don't run it on chrome debug you will get an error, run it on your emulator or smartphone

happy coding ^^

Related