Flatter Firebase Auth新更新
我有一个带有“旧”firebase auth小部件的工作应用程序。 现在,身份验证已更新,没有任何功能可用 你能帮我修一下吗 这是整个小部件:Flatter Firebase Auth新更新,firebase,flutter,dart,firebase-authentication,Firebase,Flutter,Dart,Firebase Authentication,我有一个带有“旧”firebase auth小部件的工作应用程序。 现在,身份验证已更新,没有任何功能可用 你能帮我修一下吗 这是整个小部件: import 'package:firebase_auth/firebase_auth.dart'; class AuthService { final FirebaseAuth _firebaseAuth = FirebaseAuth.instance; // ignore: deprecated_member_use Stream&l
import 'package:firebase_auth/firebase_auth.dart';
class AuthService {
final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
// ignore: deprecated_member_use
Stream<String> get onAuthStateChanged => _firebaseAuth.onAuthStateChanged.map(
(User user) => user?.uid,
);
//Email & Password Sign up
Future<String> createUserWithEmailAndPassword(
String email, String password, String name) async {
final currentUser = await _firebaseAuth.createUserWithEmailAndPassword(
email: email,
password: password,
);
//Update the Username
var userUpdateInfo = UserUpdateInfo();
userUpdateInfo.displayName = name;
await currentUser.updateProfile(userUpdateInfo);
await currentUser.reload();
return currentUser.uid;
}
//Email Password Sign In
Future<String> signInWithEmailAndPassword(
String email, String password) async {
return (await _firebaseAuth.signInWithEmailAndPassword(
email: email, password: password))
.user
.uid;
}
//Sign Out
signOut() {
return _firebaseAuth.signOut();
}
}
以下是错误:
错误:未为类型“AuthService”定义方法“UserUpdateInfo”。
错误:未为“UserCredential”类型定义方法“updateProfile”。
错误:没有为类型“UserCredential”定义方法“reload”。
错误:没有为“UserCredential”类型定义getter“uid”。您应该减少库的版本或通过此库的新文档重构代码。您应该减少库的版本或通过此库的新文档重构代码。我建议查看,并在更新的 例如,和现在在
用户
对象上定义
同一个
用户
对象也有一个,它将显示名称
作为可选的命名参数。我建议查看扑动火和更新的
例如,和现在在用户
对象上定义
同一用户
对象还有一个,它将显示名
作为可选的命名参数
//Update the Username
var userUpdateInfo = UserUpdateInfo();
userUpdateInfo.displayName = name;
await currentUser.updateProfile(userUpdateInfo);
await currentUser.reload();
return currentUser.uid;