1
votes

i am facing an issue in firebase authentication in flutter web, below i am pasting the web's index file code...

<body>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-analytics.js"></script>


<script>
  // Your web app's Firebase configuration
  var firebaseConfig = {
    apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    authDomain: "xxxxxxxxxxxxx.firebaseapp.com",
    databaseURL: "https://xxxxxxxxxxx.firebaseio.com",
    projectId: "xxxxxxxxxxxxx",
    storageBucket: "xxxxxxxxxxxxx.appspot.com",
    messagingSenderId: "xxxxxxxxxx",
    appId: "1:xxxxxxxxx:web:xxxxxxxxxxxxx",
    measurementId: "G-xxxxxxxxx"
  };
  // Initialize Firebase
  firebase.initializeApp(firebaseConfig);
  firebase.analytics();
</script>

<script src="main.dart.js" type="application/javascript"></script>
</body>

in my pubspec.yaml file i have firebase dependencies

  firebase_core: ^0.4.0+9
  firebase_analytics: ^5.0.2
  firebase_auth: ^0.14.0+5
  cloud_firestore: ^0.12.9+5
  firebase_storage: ^3.1.6
  firebase_messaging: ^6.0.16
  firebase: ^7.3.0

whole authentication code works in mobile Android/Ios but not in web and i can't see any logs the only log appears when clicking the login button second time, first time nothing happens -_- thats the main issue, any one please help me resolve my issue thanks.

Overflow on channel: plugins.flutter.io/firebase_auth. Messages on this channel are being discarded in FIFO fashion. The engine may not be running or you need to adjust the buffer size if of the channel.

MissingPluginException(No implementation found for method signInWithCredential on channel plugins.flutter.io/firebase_auth)

my signin code

    AuthResult authResult = await EmailPassAuthentication.loginWithEmail(
      // invoked on error
      () {
        if (kIsWeb) {
          showDialog(
            context: context,
            builder: (BuildContext ctx) {
              return AlertDialog(
                title: Text('Invalid Login Details'),
                content: Text('Incorrect email or password !'),
              );
            },
          );
        } else {
          showSnackBar('Incorrect email or password !', false);
        }
      },
      email: user.email,
      password: user.password,
    );
    if (authResult != null && authResult.user != null) {
      // user logged in success.
      user = await FirestoreHelper.getUserFromData(authResult.user);
//      showSnackBar('Successfuly Logged in', true);
      _navigate();
    }

and the static loginWithEmail method where i handle signin

FirebaseAuth auth = FirebaseAuth.instance;
    AuthResult authResult = await auth.signInWithEmailAndPassword(email: email, password: password).catchError(
      (error) {
        onErrorCallback.call();
      },
    );
    return authResult;
1

1 Answers

0
votes

You are using old versions of firebase, the best thing to do is to update all the dependencies. Therefore open the terminal and execute:

flutter pub outdated

The above will identify out-of-date package dependencies and get advice on how to update them, use the outdated command. For details, see the Dart pub outdated documentation.

Then execute:

flutter pub upgrade

which will upgrade the packages.

https://flutter.dev/docs/development/tools/sdk/upgrading#upgrading-packages