Home > other >  MissingPluginException (MissingPluginException(No implementation found for method Firebase#initializ
MissingPluginException (MissingPluginException(No implementation found for method Firebase#initializ

Time:07-02

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:todo_firebase/auth/authscreen.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:todo_firebase/screens/home.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Firebase.initializeApp();
  //initilization of Firebase app

  // other Firebase service initialization

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: StreamBuilder(
        stream: FirebaseAuth.instance.authStateChanges(),
        builder: (context, usersnapshot) {
          if (usersnapshot.hasData) {
            return Home();
          } else {
            return AuthScreen();
          }
        },
      ),
      debugShowCheckedModeBanner: false,
      theme: ThemeData(brightness: Brightness.light, primaryColor: Colors.blue),
      // ignore: dead_code
    );
  }
}

This is my main.dart code. I get the following output at 'await Firebase.initializeApp()': MissingPluginException (MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core))

I'm trying to make a daily task app but whenever I execute it using VSCode, it builds a Windows Application that appears blank. I've written the whole code in the different sections of lib (authentication and homepage), main.dart, and pubspec.yaml but it is not executing. Kindly provide the method to fix the error, and make my app work.

CodePudding user response:

First of all your app is not running on device If running then stop it and then Fire these command Flutter clean Then Flutter pub get

Then run your project

CodePudding user response:

There seems to be a problem with the latest firebase_core version 1.19.0 Try to use the previous version:

firebase_core: ^1.18.0

At least this solved the problem for me.

  • Related