Firebase 参数类型';int';can';不能分配给参数类型';列表<;动态>';。使用FieldValue.arrayUnion Firestore颤振时出错

Firebase 参数类型';int';can';不能分配给参数类型';列表<;动态>';。使用FieldValue.arrayUnion Firestore颤振时出错,firebase,flutter,dart,google-cloud-firestore,Firebase,Flutter,Dart,Google Cloud Firestore,我正在从RTD切换到Firestore,所以我对新db非常陌生。我正在尝试使用FieldValue.arrayUnion向文档的字段(数组)orders添加值,但是我得到参数类型“int”无法分配给参数类型“List”。。 我做错了什么? 非常感谢 // User collection _firestore .collection('Users') .doc(_firebaseAuth.currentUser.uid) .update({'orders': Fie

我正在从RTD切换到Firestore,所以我对新db非常陌生。我正在尝试使用
FieldValue.arrayUnion向文档的字段(数组)
orders
添加值,但是我得到
参数类型“int”无法分配给参数类型“List”。
。 我做错了什么? 非常感谢

// User collection
    _firestore
    .collection('Users')
    .doc(_firebaseAuth.currentUser.uid)
    .update({'orders': FieldValue.arrayUnion(order.orderId)});
将列表作为参数而不是int,因此请尝试以下操作:

.update({'orders': FieldValue.arrayUnion([order.orderId])});

…找到了。。您需要将值作为列表传递给append..因此添加方括号修复了它

_firestore
    .collection('Users')
    .doc(_firebaseAuth.currentUser.uid)
    .update({'orders': FieldValue.arrayUnion([order.orderId])});