How to fix the firebase error I get after importing firebase auth in my dart file in flutter app?

3.5k views Asked by At

I have been facing this error for weeks now, I simply can't use firebase anymore in my app. I created a new application then added firebase as required. Immediately I import firebase auth in my application I get a bunch of error. I've tired created several app and added firebase to it but still got this error. Followed tutorial to no avail

Here is my pubspec.yaml file

dependencies:
  flutter:
    sdk: flutter
  firebase_core: "^0.5.3"
  firebase_auth: "^0.18.4"
  cloud_firestore: "^0.14.4"

my dart file

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';

class AuthService {
  static final _auth = FirebaseAuth.instance;
  static final _fireStore = FirebaseFirestore.instance;

  static Future<bool> signUp(String name, String email, String password) async {
    try {
      UserCredential authResult = await _auth.createUserWithEmailAndPassword(
          email: email, password: password);

      User signedInUser = authResult.user;

      if (signedInUser != null) {
        _fireStore.collection('users').doc(signedInUser.uid).set({
          'name': name,
          'email': email,
          'profilePicture': '',
          'coverImage': '',
          'bio': ''
        });
        return true;
      }

      return false;
    } catch (e) {
      print(e);
      return false;
    }
  }

}

Error message in run the error message is long and the same every time breaking it down beginning

/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.4+1/lib/firebase_auth.dart:10:8: Error: Error when reading '/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-2.1.4/lib/firebase_auth_platform_interface.dart': The system cannot find the path specified.

import 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart';
       ^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.4+1/lib/firebase_auth.dart:15:1: Error: Error when reading '/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-2.1.4/lib/firebase_auth_platform_interface.dart': The system cannot find the path specified.

export 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart'
^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.4+1/lib/src/firebase_auth.dart:15:3: Error: Type 'FirebaseAuthPlatform' not found.
  FirebaseAuthPlatform _delegatePackingProperty;
  ^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.4+1/lib/src/firebase_auth.dart:21:3: Error: Type 'FirebaseAuthPlatform' not found.
  FirebaseAuthPlatform get _delegate {
  ^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.4+1/lib/src/firebase_auth.dart:137:10: Error: Type 'ActionCodeInfo' not found.
  Future<ActionCodeInfo> checkActionCode(String code) {
         ^^^^^^^^^^^^^^

closing

    RecaptchaVerifierOnExpired onExpired,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^


FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5m 25s
Exception: Gradle task assembleDebug failed with exit code 1

1

There are 1 answers

0
Huzaifa Ahmed On

After adding a new package must run flutter pub get in your terminal and restart your project.