Flutter 错误:方法';使用电话号码'登录;isn';t为类定义';FirebaseAuth';

Flutter 错误:方法';使用电话号码'登录;isn';t为类定义';FirebaseAuth';,flutter,dart,firebase-authentication,Flutter,Dart,Firebase Authentication,我找不到带有firebaseAuth类的带有PhoneNumber的方法的SigninWithSign //main.dart代码 signIn() { FirebaseAuth.instance .signInWithPhoneNumber(verificationId: verificationId, smsCode:smsCode) .then((user) { Navigator.of(context).pushReplacement

我找不到带有firebaseAuth类的带有PhoneNumber的方法的
SigninWithSign

//main.dart代码

signIn() {

    FirebaseAuth.instance
        .signInWithPhoneNumber(verificationId: verificationId, smsCode:smsCode)
        .then((user) {
      Navigator.of(context).pushReplacementNamed('/homepage');
    }).catchError((e) {
      print(e);
    });
  }
//pubspec.yaml代码

  dependencies:
      flutter:
        sdk: flutter



  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.

  cupertino_icons: ^0.1.2

  firebase_auth:

FirebaseAuth

要在代码发送给用户后使用电话号码签名,请使用
signwithcredential
方法

例如:如果传递的代码为true,则此方法将返回firebaseUser,如果不为true,则返回null

Future<FirebaseUser> getUserFromCodePhone(
      String code, String verificationID) async {
    FirebaseAuth mAuth = FirebaseAuth.instance;

    AuthCredential phoneAuthCredential = PhoneAuthProvider.getCredential(
        verificationId: verificationID, smsCode: code);
    try {
      AuthResult result = await mAuth.signInWithCredential(phoneAuthCredential);

      FirebaseUser currentUser = await mAuth.currentUser();
      if (currentUser != null && result.user.uid == currentUser.uid) {
        return currentUser;
      } else {
        return null;
      }
    } on PlatformException catch (_) {}

    return null;
  }
未来的getUserFromCodePhone(
字符串代码,字符串验证ID)异步{
FirebaseAuth mAuth=FirebaseAuth.instance;
AuthCredential phoneAuthCredential=PhoneAuthProvider.getCredential(
验证ID:verificationId,smsCode:code);
试一试{
AuthResult结果=等待mAuth.signInWithCredential(phoneAuthCredential);
FirebaseUser currentUser=等待mAuth.currentUser();
if(currentUser!=null&&result.user.uid==currentUser.uid){
返回当前用户;
}否则{
返回null;
}
}平台上异常捕获({}
返回null;
}

@BhagyashreeR欢迎朋友,如果我的答案能解决您的问题,请更正