I got this problem at sign in function with firebase, I don't know how to solve it. Please help, thanks.
the code of my sign in function is like:
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);
}
}
}
and my flutter doctor is like:
[✓] 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)
the output of the error is like:
[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<…>
It happens both on my device and IOS simulator, and I didn't try it on android. I have already tried the flutter clean, start a new project, and upgrade the cocoaPods. But none of them is useful to my case. Thanks for help.
It seems that whenever I try to do something with firebase, it will come up to this kind of question. I wrote code to sign up like this:
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)));
}
}
The output of my code is
[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)
And I'm sure I finished the setup of firebase and successfully connected flutter app with firebase.
I had a really hard time in making Firebase work. I think it should be REALLY easy, as both Flutter and Firebase are Google products. Anyway, I had to use this code for the AppDelegate.m
file in iOS:
#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
Have you tried something like this already?
I got same issue and solve it by upgrading firebase_auth package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With