Closed woohelps closed 3 years ago
hyy dude i also ran into same problem then added this additional code in main.dart file
class MyApp extends StatelessWidget {
final Future<FirebaseApp> _initialization = Firebase.initializeApp();
Widget build(BuildContext context) {
return FutureBuilder(
future: _initialization,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return MaterialApp(
title: 'Compound',
builder: (context, child) => Navigator(
key: locator<DialogService>().dialogNavigationKey,
onGenerateRoute: (settings) => MaterialPageRoute(
builder: (context) => DialogManager(child: child)),
),
navigatorKey: locator<NavigationService>().navigationKey,
theme: ThemeData(
primaryColor: Color.fromARGB(255, 9, 202, 172),
backgroundColor: Color.fromARGB(255, 26, 27, 30),
textTheme: Theme.of(context).textTheme.apply(
fontFamily: 'Open Sans',
),
),
home: StartUpView(),
onGenerateRoute: generateRoute,
);
}
},
);
}
}
Another solution (as mentioned in this StackOverflow post) is to only change main
in main.dart
to the following:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
setupLocator();
runApp(new myApp());
}
That way, MyApp
can be left untouched.
Did the suggestions above solve the problem?
Did the suggestions above solve the problem?
Yes, it works!
Hi There,
I am new to flutter, your tutorial is very good and helps me a lot. when I follow the 038-firebase-authentication tutorial, I got the below error:
I/flutter (32447): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter (32447): The following FirebaseException was thrown building SignUpView: I/flutter (32447): [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()
Then I found the answer:https://stackoverflow.com/a/63492262/4339371
I have no idea how to add
Firebase.initializeApp()
in theget it locator,
could you let me know how to update the code for the new version of firebase?I tried to add
Firebase.initializeApp()
in my code but doesn't work. Here is my git repo: https://github.com/woohelps/firebase_app/blob/firebase_new_version/README.md