Flutter 如何使用googleSignIn未来方法中的命名路线导航?

Flutter 如何使用googleSignIn未来方法中的命名路线导航?,flutter,dart,google-signin,Flutter,Dart,Google Signin,我在一个名为auth.dart的单独文件中的AuthService类中有googleSignIn方法 //在AuthService类中 /.../ Future googleSignIn()异步{ 加载。添加(true); GoogleSignInAccount googleUser=wait_googleSignIn.signIn(); GoogleSignInAuthentication googleAuth=等待googleUser.authentication; final AuthCr

我在一个名为auth.dart的单独文件中的AuthService类中有googleSignIn方法

//在AuthService类中
/.../
Future googleSignIn()异步{
加载。添加(true);
GoogleSignInAccount googleUser=wait_googleSignIn.signIn();
GoogleSignInAuthentication googleAuth=等待googleUser.authentication;
final AuthCredential credential=GoogleAuthProvider.getCredential(
accessToken:googleAuth.accessToken,
idToken:googleAuth.idToken,
);
最终FirebaseUser用户=使用凭证(凭证)等待身份验证登录;
updateUserData(用户);
打印(“登录”+user.displayName);
加载。添加(假);
返回用户;
}
/.../
在登录页面(LogInPage.dart),我有一个谷歌登录按钮

//在_loginpagentate类中
/.../
社会党人(
颜色:[颜色(0xffcb2d3e),颜色(0xFFF473A)],
图标:图标(
FontAwesomeIcons.google,
颜色:颜色,白色,
),
已按下:(){
final login=authService.googleSignIn();
登录。然后(/*使用命名路由导航到主页*/);
},
),
/.../
在onPressed中完成googleSignIn()之后,我正在尝试执行下面的代码

Navigator.of(context).pushName和removeUntil(
“/home”,(路由)=>false);

我该怎么做?

因为你的
谷歌登录
返回未来。 您只需使用
然后
并导航到所需的小部件

    googleSignIn().then((FirebaseUser user) {
      //Navigation code here
    }).catchError((e) {
      //Error if any
    });