我在使用Firebase登录功能时遇到了这个问题,我不知道如何解决。请帮助,谢谢。
我登录功能的代码如下:
Future<void> signIn() async{
final formState = _formKey.currentState;
if(formState.validate()){
//TODO login to firebase
formState.save();
try{
FirebaseUser user = await FirebaseAuth.instance.signInWithEmailAndPassword(email: _email, password: _password);
Navigator.push(context, MaterialPageRoute(builder: (context)=> Home(user: user)));
}catch(e){
print(e.details);
}
}
}
我的扑打医生就像:
[✓] Flutter (Channel master, v1.4.20-pre.2, on Mac OS X 10.14.4 18E226, locale
zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2)
[!] Android Studio (version 3.3)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.8)
[✓] VS Code (version 1.33.1)
[✓] Connected device (1 available)
错误的输出如下:
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception:
MissingPluginException(No implementation found for method signInWithCredential on channel plugins.flutter.io/firebase_auth)
0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:300:7)
<asynchronous suspension>
1 FirebaseAuth.signInWithCredential (package:firebase_auth/src/firebase_auth.dart:278:54)
<asynchronous suspension>
2 FirebaseAuth.signInWithEmailAndPassword (package:firebase_auth/src/firebase_auth.dart:249:12)
3 _LoginPageState.signIn (package:pdc/Pages/Setup/signIn.dart:62:57)
<asynchronous suspension>
4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
5 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
7 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
8 TapGestureR<…>
它同时在我的设备和IOS模拟器上发生,并且我没有在android上尝试过。 我已经尝试了清除抖动,启动新项目并升级cocoaPods。但是它们都不对我的情况有用。 感谢您的帮助。
似乎,每当我尝试使用firebase进行操作时,都会遇到此类问题。 我写了这样的代码进行注册:
Future<void> signUp() async{
if(_formKey.currentState.validate()){
_formKey.currentState.save();
FirebaseUser user = await FirebaseAuth.instance.createUserWithEmailAndPassword(email: _email, password: _password);
Navigator.push(context, MaterialPageRoute(builder: (context)=> Home(user: user)));
}
}
我的代码的输出是
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method createUserWithEmailAndPassword on channel plugins.flutter.io/firebase_auth)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:300:7)
<asynchronous suspension>
#1 FirebaseAuth.createUserWithEmailAndPassword (package:firebase_auth/src/firebase_auth.dart:108:54)
<asynchronous suspension>
#2 _LoginPageState.signUp (package:pdc/Pages/Setup/signIn.dart:78:55)
<asynchronous suspension>
#3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
#4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
#5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
#6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
#7 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:177:9)
#8 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:436:9)
我确定我已经完成了Firebase的设置,并成功将flutter应用程序与Firebase连接。
答案 0 :(得分:0)
我相信您需要运行获取和升级软件包。 如果您使用的是Android Studio,则只需进入pubspeck.yaml文件,两个按钮将显示在右上角,或者您可以使用终端。
答案 1 :(得分:0)
在使Firebase正常工作方面我真的很难。我认为这应该真的很容易,因为Flutter和Firebase都是Google产品。无论如何,我必须在iOS中的AppDelegate.m
文件中使用以下代码:
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
@import UIKit;
@import Firebase;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
[GeneratedPluginRegistrant registerWithRegistry:self];
return [super application:application didFinishLaunchingWithOptions:launchOptions]; // YES;
}
@end
您已经尝试过类似的方法吗?
答案 2 :(得分:0)
我遇到了同样的问题,并通过升级firebase_auth软件包来解决它。