(flutter web) TypeError: Cannot read properties of undefined (reading 'auth')

Viewed 28

I have a flutter web project and I use firebase services, The project was working perfectly until I add the package "cloud_functions 3.3.7", a problem appaired in firebase auth.

TypeError: Cannot read properties of undefined (reading 'auth')

I tried to remove the package "cloud_functions 3.3.7" and the problem is still the same.

I tried to add these packages in index.html.

<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-storage.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-messaging.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-analytics.js"></script>

it shows this error

FirebaseError: Firebase: firebase.auth() takes either no argument or a Firebase App instance. (app/invalid-app-argument).

code to init Firebase

await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
dependencies:
  firebase_core: ^1.13.1
  firebase_analytics: ^9.1.2
  firebase_auth: ^3.3.10
  cloud_firestore: ^3.1.10
  cloud_functions: ^3.3.7 
  firebase_storage: ^10.2.9
1 Answers

I create a new project flutter and I replace the files(lib, assets,..) and add packages in pubspec.yaml and it works perfectly and link it with firebase.

dart pub global activate flutterfire_cli
flutterfire configure --project=your_project_id

it's not a perfect solution but it still works.

Related