[FirebaseAuth]: flutter Only on web platform exception at FirebaseAuth.instance #13475
Open
1 task done
Labels
blocked: customer-response
Waiting for customer response, e.g. more information was requested.
platform: web
Issues / PRs which are specifically for web.
plugin: auth
type: bug
Something isn't working
Is there an existing issue for this?
Which plugins are affected?
Auth
Which platforms are affected?
Web
Description
When I use the FirebaseAuth.instance I get the following exception, only on web unfortunately, everything works fine on Andriod.
FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call initializeApp() first (app/no-app).
I have tried many thing, not sure what to do after spending 2 hours on this. Please help.
Reproducing the issue
This is how my main.dart looks like
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'app.dart';
import 'data/repositories/authentication/authentication_repository.dart';
import 'firebase_options.dart';
Future main() async {
// Ensure that the WidgetsBinding has been initialized before calling Firebase.initializeApp
final WidgetsBinding widgetsBinding =
WidgetsFlutterBinding.ensureInitialized();
// Initialize GetStorage to store data locally
await GetStorage.init();
// Await SplashScreen until other services are initialized
if (!kIsWeb) FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
// Initialize Firebase with the default options and the current platform configuration (Android, iOS, web, etc.)
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
name: 'App-Name',
).then((app) {
// Initialize Firestore with the FirebaseApp instance
//Get.put(FirebaseFirestore.instanceFor(app: app));
// Initialize the Firebase Authentication with the FirebaseApp instance
//Get.put(FirebaseAuth.instanceFor(app: app));
// Then initialize the AuthenticationRepository with the FirebaseApp instance
Get.put(AuthenticationRepository());
});
runApp(const MainApp());
}
I am calling the final _auth = FirebaseAuth.instance; in AuthenticationRepository.
Firebase Core version
3.6.0
Flutter Version
3.5.2
Relevant Log Output
Flutter dependencies
Expand
Flutter dependencies
snippetReplace this line with the contents of your `flutter pub deps -- --style=compact`.
Additional context and comments
No response
The text was updated successfully, but these errors were encountered: