【发布时间】:2021-05-04 00:17:54
【问题描述】:
我想显示来自 Firestore 的用户图像。但是显示错误。显示带有此错误的图像。'package:flutter/src/painting/_network_image_io.dart':断言失败:第 26 行 pos 16:'url != null':不正确。
class _ChatRoomListTileState extends State<ChatRoomListTile> {
String profilePicUrl = "",
name = "",
username = "";
getThisUserInfo() async {
username =
widget.chatRoomId.replaceAll(widget.myUserName, "").replaceAll("_", "");
QuerySnapshot querySnapshot = await DatabaseMethods().getUserInfo(username);
// print("something the data we are getting ${querySnapshot.docs[0].id}");
name = "${querySnapshot.docs[0]["name"]}";
profilePicUrl = querySnapshot.docs[0]["imgUrl"];
setState(() {});
}
@override
void initState() {
getThisUserInfo();
super.initState();
}
连续显示里面的图片
ClipRRect(
borderRadius: BorderRadius.circular(30),
child: Image(
height: 45.0,
width: 45.0,
image: NetworkImage(profilePicUrl) == null
? AssetImage('assets/images/emoteU.png')
: NetworkImage(profilePicUrl),
),
),
【问题讨论】:
-
不应该是
image: NetworkImage(profilePicUrl) == null ? ...是image: profilePicUrl == null ? ...吗? -
我试过这个。但显示此错误
type 'NetworkImage' is not a subtype of type 'String' where -
我在 huwai 设备上运行应用程序时遇到同样的错误。在其他设备上,应用程序运行正常,没有任何错误。我不确定为什么会收到此错误。
-
请分享您的代码
标签: firebase flutter dart flutter-web