'where should i insert "Firebase.initializeApp()"
where should I have to insert "Firebase.initializeApp()" In the "login.dart" page
CODE = <https://pastebin.com/zgnaF8u6>
IMAGE = img
Solution 1:[1]
You have to only call Firebase.initializeApp() in your main function. Delete that everywhere else and move it to main.dart or main() for example:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(); //call it before runApp()
runApp(MyApp());
}
Solution 2:[2]
You really only have to include it in your main-function and nowhere else... See example
example:
main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(
const YourHomeScreen(),
);
}
Solution 3:[3]
main.dart like:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(
const MyApp(),
);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Dharman |
| Solution 3 | Simon Danninger |
