Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 更新Firebase用户的用户信息_Flutter - Fatal编程技术网

Flutter 更新Firebase用户的用户信息

Flutter 更新Firebase用户的用户信息,flutter,Flutter,我试图在用户注册时更新显示名称和图像URL 我的程序流程是: 注册表(图像、用户名、电子邮件、密码)->验证电子邮件->验证后->将图像上载到firebase存储->获取URL->更新用户信息 数据已更新,我可以在控制台中看到它,但当我进入主屏幕时,它不会显示。我需要刷新应用程序,然后才能看到数据 我是不是遗漏了什么 if(_otpMatches) { FocusScope.of(context).requestFocus(new FocusNode()); Navigato

我试图在用户注册时更新显示名称和图像URL

我的程序流程是:

注册表(图像、用户名、电子邮件、密码)->验证电子邮件->验证后->将图像上载到firebase存储->获取URL->更新用户信息

数据已更新,我可以在控制台中看到它,但当我进入主屏幕时,它不会显示。我需要刷新应用程序,然后才能看到数据

我是不是遗漏了什么

  if(_otpMatches) {
    FocusScope.of(context).requestFocus(new FocusNode());
    Navigator.pop(context);

    setState( () => loading = true);

    //Sign Up user
    Provider.of<AuthService>(context,listen: false)
        .registerUser(_emailController.text,
        _passwordController.text).whenComplete(() async {

          print('username - ${_userNameController.text}');

          User _user = FirebaseAuth.instance.currentUser;

          //Upload user image
          await storage.ref(fileName).putFile(
                imageFile,
                SettableMetadata(customMetadata: {
                  'uploaded_by': _userNameController.text,
                  'description': DateTime.now().toString()})
            ).whenComplete(() async {
              _url = await FirebaseStorage.instance
                  .ref(fileName).getDownloadURL();

              //Update User details
              await _user.updateProfile(
                  displayName: _userNameController.text,
                  photoURL: _url).whenComplete(() {
              });
            });
    }); }
return Scaffold(
    backgroundColor: Colors.white,
    body: ChangeNotifierProvider(
      create: (context) => AuthService(),
      child: StreamBuilder(
        stream: FirebaseAuth.instance.authStateChanges(),
        builder: (context,snapshot) {

          if(snapshot.hasData) {
            return Home();
          }
          else
            {
              return Toggle();
            }
        }
      ),
    ),
);