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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.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 方法';containsKey';isn';t为类型';函数';。我怎样才能修好它? var数据={ “photoUrl”:profileImageUrl, “年龄”:年龄, “用户名”:用户名, }; //ref.setData(数据,合并:真); 参考集(数据); SetOptions(合并:true); final DocumentSnapshot currentDocument=等待参考get(); 从FireStore返回实用程序(currentDocument); } @凌驾 未来isProfileComplete(字符串uid)异步{ DocumentReference ref=fireStoreDb.collection(path.usersPath.doc(uid)); final DocumentSnapshot currentDocument=等待参考get(); 返回(currentDocument.exists)&& currentDocument.data.containsKey('username')&&//此处有错误 currentDocument.data.containsKey('age');//此处出错_Flutter_Dart_Maps - Fatal编程技术网

Flutter 方法';containsKey';isn';t为类型';函数';。我怎样才能修好它? var数据={ “photoUrl”:profileImageUrl, “年龄”:年龄, “用户名”:用户名, }; //ref.setData(数据,合并:真); 参考集(数据); SetOptions(合并:true); final DocumentSnapshot currentDocument=等待参考get(); 从FireStore返回实用程序(currentDocument); } @凌驾 未来isProfileComplete(字符串uid)异步{ DocumentReference ref=fireStoreDb.collection(path.usersPath.doc(uid)); final DocumentSnapshot currentDocument=等待参考get(); 返回(currentDocument.exists)&& currentDocument.data.containsKey('username')&&//此处有错误 currentDocument.data.containsKey('age');//此处出错

Flutter 方法';containsKey';isn';t为类型';函数';。我怎样才能修好它? var数据={ “photoUrl”:profileImageUrl, “年龄”:年龄, “用户名”:用户名, }; //ref.setData(数据,合并:真); 参考集(数据); SetOptions(合并:true); final DocumentSnapshot currentDocument=等待参考get(); 从FireStore返回实用程序(currentDocument); } @凌驾 未来isProfileComplete(字符串uid)异步{ DocumentReference ref=fireStoreDb.collection(path.usersPath.doc(uid)); final DocumentSnapshot currentDocument=等待参考get(); 返回(currentDocument.exists)&& currentDocument.data.containsKey('username')&&//此处有错误 currentDocument.data.containsKey('age');//此处出错,flutter,dart,maps,Flutter,Dart,Maps,我不熟悉颤振和OOP。这是我正在学习的一些项目教程。但是项目中使用的颤振版本已被弃用。因此,我在升级它时遇到了此问题。以前的版本似乎对此没有问题。有人可以帮助我吗 dataproperty on是一种返回文档快照内容的方法。您需要先执行它,然后才能访问映射的属性 var data = { 'photoUrl': profileImageUrl, 'age': age, 'username': username, }; //ref.set

我不熟悉颤振和OOP。这是我正在学习的一些项目教程。但是项目中使用的颤振版本已被弃用。因此,我在升级它时遇到了此问题。以前的版本似乎对此没有问题。有人可以帮助我吗


data
property on是一种返回文档快照内容的方法。您需要先执行它,然后才能访问映射的属性

    var data = {
      'photoUrl': profileImageUrl,
      'age': age,
      'username': username,
    };
    //ref.setData(data, merge: true);
    ref.set(data);
    SetOptions(merge: true);
    final DocumentSnapshot currentDocument = await ref.get();
    return Utilizer.fromFirestore(currentDocument);
  }
 @override
  Future<bool> isProfileComplete(String uid) async {
    DocumentReference ref = fireStoreDb.collection(Paths.usersPath).doc(uid);
    final DocumentSnapshot currentDocument = await ref.get();

    return (currentDocument.exists &&
        
        currentDocument.data.containsKey('username') &&  //error here
        currentDocument.data.containsKey('age'));        //error here

谢谢您的回答。但是现在它说,“没有为类型“Object”定义方法“containsKey”。“您可能希望尝试将其强制转换为map
为map
或添加键入信息-DocumentSnapshot/DocumentReference具有通用属性t-
DocumentReference
currentDocument.data().containsKey('username')