This is working for web but not for android. And when i comment out options:FirebaseOptions() it works for android and not for web.
Code: which works for web
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: FirebaseOptions(
apiKey: "---",
appId: "---",
messagingSenderId: "---",
projectId: "---",
));
runApp(const MyApp());
}
Error For android: a firebase app named "[default]" already exists
Code: which works for android
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());
}
Error for web: FirebaseOptions cannot be null when creating the default app
if (kIsWeb) {
await Firebase.initializeApp(
options: FirebaseOptions(
apiKey: "---",
appId: "---",
messagingSenderId: "---",
projectId: "---",
));
} else
await Firebase.initializeApp();
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initFireBase();
runApp(const MyApp());
}```