简体   繁体   English

Flutter Web:MissingPluginException(在频道 plugins.flutter.io/firebase_auth 上找不到方法 startListeningAuthState 的实现)

[英]Flutter Web: MissingPluginException(No implementation found for method startListeningAuthState on channel plugins.flutter.io/firebase_auth)

I recently converted my Flutter Firebase app to to Flutter Web and I'm getting this error after trying to sign in or register:我最近将我的 Flutter Firebase 应用程序转换为 Flutter Web 并在尝试登录或注册后收到此错误:

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

I added new web app to my Firebase project, pasted the code and it doesn't seem to work.我在 Firebase 项目中添加了新的网络应用程序,粘贴了代码,但它似乎不起作用。 Any solutions?任何解决方案? I would like to keep my code as much the same as it can, but i will apreciate every answer.我想尽可能保持我的代码相同,但我会感谢每个答案。 Thanks!谢谢! My index.html:我的 index.html:

 <body> <!-- The core Firebase JS SDK is always required and must be listed first --> <script src="https://www.gstatic.com/firebasejs/7.21.1/firebase-app.js"></script> <!-- TODO: Add SDKs for Firebase products that you want to use https://firebase.google.com/docs/web/setup#available-libraries --> <script src="https://www.gstatic.com/firebasejs/7.21.1/firebase-analytics.js"></script> <script src="https://www.gstatic.com/firebasejs/7.21.1/firebase-auth.js"></script> <script src="https://www.gstatic.com/firebasejs/7.21.1/firebase-firestore.js"></script> <script> // Your web app's Firebase configuration // For Firebase JS SDK v7.20.0 and later, measurementId is optional var firebaseConfig = { apiKey: "**", authDomain: "***", databaseURL: "h****", projectId: "%%%", storageBucket: "%%%%", messagingSenderId: "%%%%", appId: "%%%%", measurementId: "%%%%" }; // Initialize Firebase if(!firebase.apps.length){ firebase.initializeApp(firebaseConfig); firebase.analytics(); firebase.auth(); firebase.firestore(); }; </script> <!-- This script installs service_worker.js to provide PWA functionality to application. For more information, see: https://developers.google.com/web/fundamentals/primers/service-workers --> <script> if ('serviceWorker' in navigator) { window.addEventListener('load', function () { navigator.serviceWorker.register('flutter_service_worker.js'); }); } </script> <script src="main.dart.js" type="application/javascript"></script> </body>

My pubspec.yaml:我的 pubspec.yaml:

 dependencies: flutter: sdk: flutter firebase_auth: ^0.14.0+5 cloud_firestore: ^0.12.9+4 firebase_core: ^0.4.4+3 firebase_storage: 3.0.4 provider: ^3.1.0 image_cropper: ^1.2.0 image_picker: ^0.6.5 outline_gradient_button: ^1.0.0+2 page_transition: ^1.1.6 share: ^0.6.4+3 intl: ^0.16.1 photo_view: ^0.10.2 skeleton_text: ^1.0.0 url_launcher: ^5.4.5 admob_flutter: ^0.3.4 file_picker: ^2.0.0 flutter_downloader: ^1.5.0 path_provider: ^1.6.18 permission_handler: ^5.0.1+1 ext_storage: ^1.0.3 connectivity: ^0.4.9+3

My auth.dart:我的 auth.dart:

 import 'package:classy/pages/blank.dart'; import 'package:flutter/material.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/services.dart'; import 'user.dart'; class AuthService { String exceptionError; final FirebaseAuth _auth = FirebaseAuth.instance; //Creating user object User userFromFirebaseUser(FirebaseUser user){ return user != null ? User(uid: user.uid) : null; } void currentUser() async{ final FirebaseUser user = await _auth.currentUser(); } //auth change user stream Stream<User> get user{ return _auth.onAuthStateChanged.map((FirebaseUser user) => userFromFirebaseUser(user)); } //Registering with email and password Future register(String email, String password, context) async { try{ AuthResult result = await _auth.createUserWithEmailAndPassword(email: email, password: password); FirebaseUser user = result.user; Navigator.popUntil(context, ModalRoute.withName("/")); // Navigator.pushReplacementNamed(context, '/wrapper'); return userFromFirebaseUser(user); } on PlatformException catch(e){ if(e.message.startsWith('The email address is already in use')){ exceptionError='Użytkownik z podanym adresem email już istnieje'; } if(e.message.startsWith('The email address is badly formatted')){ exceptionError='Wpisz poprawny adres email'; } return null; } } //Logging with email and password Future login(String email, String password, context) async { try{ AuthResult result = await _auth.signInWithEmailAndPassword(email: email, password: password); FirebaseUser user = result.user; Navigator.pop(context); return userFromFirebaseUser(user); } on PlatformException catch(e){ if(e.message.startsWith('The password is invalid')){ exceptionError='Wpisz poprawne hasło'; } if(e.message.startsWith('There is no user record')){ exceptionError='Użytkownik z podanym email nie istnieje'; } return null; } } }

Update your FireAuth version to firebase_auth: ^0.18.4+1 if during the update of pubspec any other error was presented, update the other dependencies to updated versions.将您的 FireAuth 版本更新为 firebase_auth: ^0.18.4+1 如果在 pubspec 更新期间出现任何其他错误,请将其他依赖项更新为更新版本。

[Resposta em BR] [Resposta em BR]

atualize a versão do seu FireAuth para firebase_auth: ^0.18.4+1 se durante a atualização do pubspec algum outro erro foi apresentado atualize as demais dependências para versões atualizadas. atualize a versão do seu FireAuth para firebase_auth: ^0.18.4+1 se durante a atualização do pubspec algum outro erro foi apresentado atualize as demaisdependentências para versões atualizadas。

What worked for me was to delete/comment out all firebase related dependencies and reinstall one by one using flutter pub add *dependency name*对我有用的是删除/注释掉所有与 firebase 相关的依赖项,然后使用flutter pub add *dependency name*一一重新安装

This ensured I had the latest dependencies installed and there were no conflicts这确保我安装了最新的依赖项并且没有冲突

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MissingPluginException(在通道插件上找不到方法 signInAnonymously 的实现。flutter.io/firebase_auth) - MissingPluginException(No implementation found for method signInAnonymously on channel plugins.flutter.io/firebase_auth) MissingPluginException(在通道 plugins.flutter.io/firebase_auth 上没有找到方法 signInWithCredential 的实现) - MissingPluginException(No implementation found for method signInWithCredential on channel plugins.flutter.io/firebase_auth) Flutter MissingPluginException(在通道插件上找不到方法 loadInterstitialAd 的实现。flutter.io/firebase_admob) - Flutter MissingPluginException(No implementation found for method loadInterstitialAd on channel plugins.flutter.io/firebase_admob) MissingPluginException(在通道 plugins.flutter.io/firebase_core 上找不到方法 Firebase#initializeCore 的实现)在测试中 - MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core) on tests MissingPluginException(未找到通道插件上的方法 Firebase#initializeCore 的实现。flutter.io/firebase_core)发布 - MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core) on release MissingPluginException(在 Android 上找不到方法 Firebase#initializeCore 在通道插件上的实现。flutter.io/firebase_core) - MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core) on Android iOS:MissingPluginException(在通道插件上找不到方法 Firebase#initializeCore 的实现。flutter.io/firebase_core) - iOS: MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core) 缺少插件异常(在通道插件上找不到方法 firebase#initializecore 的实现。flutter.io/firebase_core) - missingpluginexception(no implementation found for method firebase#initializecore on channel plugins.flutter.io/firebase_core) MissingPluginException(在通道插件上找不到方法 FirebaseApp#appNamed 的实现。flutter.io/firebase_core) - MissingPluginException(No implementation found for method FirebaseApp#appNamed on channel plugins.flutter.io/firebase_core) MissingPluginException(在通道插件上找不到方法 getToken 的实现。flutter.io/firebase_messaging) - MissingPluginException(No implementation found for method getToken on channel plugins.flutter.io/firebase_messaging)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM