我正在从flutter设计用于Android设备的聊天应用程序,但是当我添加了用于Firebase身份验证的插件时,它给出了以下异常。我接受你的答复。预先谢谢你!
Flutter: MissingPluginException(No implementation found for method createUserWithEmailAndPassword on channel plugins.flutter.io/firebase_auth)
这是“注册”屏幕中的代码
class _RegistrationScreenState extends State<RegistrationScreen> {
final _auth = FirebaseAuth.instance;
String email;
String password;
.
.
.
onPressed: () async{
try {
final newUser = await _auth.createUserWithEmailAndPassword(
email: email, password: password);
if(newUser!=null){
Navigator.pushNamed(context, ChatScreen.id);
}
}catch(e){
print(e);
}
},
这是“聊天”屏幕中的代码
class _ChatScreenState extends State<ChatScreen> {
final _auth = FirebaseAuth.instance;
FirebaseUser loggedInUser;
@override
void initState(){
super.initState();
getCurrentUser();
}
void getCurrentUser() async{
try {
final user = await _auth.currentUser();
if (user != null) {
loggedInUser = user;
print(loggedInUser.email);
}
}catch(e){
print(e);
}
}
.
.
.
答案 0 :(得分:2)
在添加新插件并添加新资产后,建议完全重启。