Issue
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.
Solution
Had this issue this morning.. What a problem it was! Took me a few hours to figure out. Everything is working now though!
What did I do? I tried cleaning my project out, deleted ios file and ran flutter create .
a few times with no luck... Pulled my hair out!
What fixed it?
- update your gems
- delete ios file for the 5th time (LOL)
- delete "derived data" in xcode and clean build folder in xcode
run flutter clean
inside your project and then run flutter pub cache repair
Then you need to manually update your pubspec.yaml with the latest version of firebase core, etc. Yes make sure you delete lock file first then manually update the dependencies. DO NOT run flutter pub upgrade
. Won't work.. Just manually add them in :(
This is what I manually added into my pubspec.yaml:
cloud_firestore: ^3.2.1
firebase_core: ^1.19.1
firebase_storage: ^10.3.1
firebase_auth: ^3.4.1
firebase_messaging: ^11.4.4
Answered By - Julia Pak
Answer Checked By - Mildred Charles (JavaFixing Admin)