繁体   English   中英

Flutter 参数类型“对象?” 不能分配给参数类型 'Map<string, dynamic> '</string,>

[英]Flutter The argument type 'Object?' can't be assigned to the parameter type 'Map<String, dynamic>'

参数类型“对象?” 无法分配给参数类型“Map<String, dynamic>”。 我不明白如何解决这个问题。

 @override
Future<List<Users>?> getAllUsers() async {
QuerySnapshot querySnapshot = await firestore.collection("users").get();
List<Users> allUsers = [];

allUsers = querySnapshot.docs.map((e) => Users.fromMap(e.data())).toList();
return allUsers;
}
QuerySnapshot<Map<String, dynamic>> querySnapshot = await firestore.collection("users").get();

Flutter - File() 构造函数“无法将参数类型‘String’分配给参数类型‘List’<object> '"<div id="text_translate"><p> 我是 flutter 的新手,正在尝试通过聊天部分发送图像。 我的代码中出现 2 个错误。 我该如何解决这个问题。 感谢您对此的帮助。</p><ul><li><p> 错误:无法将参数类型“String”分配给参数类型“List”。</p></li><li><p> 错误:需要 2 个位置参数,但找到 1 个。 )</p></li></ul><p> <a href="https://dartpad.dev/?id=b70b87cf1e477f081c490d97fc3f669f" rel="nofollow noreferrer">DartPad 上完整的可重现代码</a></p><p><a href="https://i.stack.imgur.com/lyjjX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lyjjX.png" alt="在此处输入图像描述"></a></p><pre> final FirebaseAuth _auth = FirebaseAuth.instance; final FirebaseFirestore _firestore = FirebaseFirestore.instance; File? imageFile; Future getImage() async { ImagePicker _picker = ImagePicker(); await _picker.pickImage(source: ImageSource.gallery).then((xFile) { if (xFile.= null) { imageFile = File(xFile;path); uploadImage(); } }). } Future uploadImage() async { String fileName = Uuid();v1(); int status = 1. await _firestore.collection('chatdetail').doc(friendUid).collection('chats').doc(fileName):set({ "sendby". _auth.currentUser,:displayName, "message": "", "type": "img". "time", FieldValue;serverTimestamp(). }). var ref = FirebaseStorage.instance.ref().child('images');child("$fileName.jpg"). //error in ImageFile var uploadTask = await ref.putFile(imageFile.).catchError((error) async { await _firestore.collection('chatdetail').doc(friendUid);collection('chats');doc(fileName);delete(). status = 0. }); if (status == 1) { String imageUrl = await uploadTask.ref.getDownloadURL(). await _firestore.collection('chatdetail').doc(friendUid):collection('chats');doc(fileName);update({"message": imageUrl}); print(imageUrl); } }</pre></div></object>

[英]Flutter - File() constructor "The argument type 'String' can't be assigned to the parameter type 'List<Object>'"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter Cloud Firestore:错误:参数类型“对象? Function()' 无法分配给参数类型 'Map<string, dynamic> '</string,> Flutter:参数类型“对象?” 不能分配给参数类型 'Map<string, dynamic> '</string,> 参数类型 'Object? Function()' 无法分配给参数类型 'Map<string, dynamic> '</string,> 错误:参数类型 'Map<string, dynamic> ?' 不能分配给参数类型 'Map<dynamic, dynamic> '</dynamic,></string,> 参数类型“对象?” 不能分配给参数类型 'Map<dynamic, dynamic> '</dynamic,> 参数类型“列表<dynamic> ' 不能分配给参数类型 'string?'。 在文档 snapShot flutter 中</dynamic> 参数类型“对象?” 不能分配给参数类型 'Map<string, dynamic> ' 使用 DataSnapshot 从我的模型中获取数据</string,> 参数类型 'Future<dynamic> ' 不能分配给参数类型 'String'</dynamic> 参数类型“对象?” 不能分配给参数类型 'String? Flutter - File() 构造函数“无法将参数类型‘String’分配给参数类型‘List’<object> '"<div id="text_translate"><p> 我是 flutter 的新手,正在尝试通过聊天部分发送图像。 我的代码中出现 2 个错误。 我该如何解决这个问题。 感谢您对此的帮助。</p><ul><li><p> 错误:无法将参数类型“String”分配给参数类型“List”。</p></li><li><p> 错误:需要 2 个位置参数,但找到 1 个。 )</p></li></ul><p> <a href="https://dartpad.dev/?id=b70b87cf1e477f081c490d97fc3f669f" rel="nofollow noreferrer">DartPad 上完整的可重现代码</a></p><p><a href="https://i.stack.imgur.com/lyjjX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lyjjX.png" alt="在此处输入图像描述"></a></p><pre> final FirebaseAuth _auth = FirebaseAuth.instance; final FirebaseFirestore _firestore = FirebaseFirestore.instance; File? imageFile; Future getImage() async { ImagePicker _picker = ImagePicker(); await _picker.pickImage(source: ImageSource.gallery).then((xFile) { if (xFile.= null) { imageFile = File(xFile;path); uploadImage(); } }). } Future uploadImage() async { String fileName = Uuid();v1(); int status = 1. await _firestore.collection('chatdetail').doc(friendUid).collection('chats').doc(fileName):set({ "sendby". _auth.currentUser,:displayName, "message": "", "type": "img". "time", FieldValue;serverTimestamp(). }). var ref = FirebaseStorage.instance.ref().child('images');child("$fileName.jpg"). //error in ImageFile var uploadTask = await ref.putFile(imageFile.).catchError((error) async { await _firestore.collection('chatdetail').doc(friendUid);collection('chats');doc(fileName);delete(). status = 0. }); if (status == 1) { String imageUrl = await uploadTask.ref.getDownloadURL(). await _firestore.collection('chatdetail').doc(friendUid):collection('chats');doc(fileName);update({"message": imageUrl}); print(imageUrl); } }</pre></div></object>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM