【发布时间】:2021-01-21 06:07:52
【问题描述】:
我正在尝试在 CircleAvatar() 中显示用户图像 URL;即使我提供了它,它也显示一个空错误。还是我做错了?
首先我调用 Auth Methods 和 Set image String img,
AuthMethods _auth = AuthMethods();
String img;
然后我在 initstate 中实例化
_auth.getCurrentUser().then((user) async {
setState(() {
user.uid;
img = user.photoUrl
});
});
}
然后在Drawer()
中调用 DrawerHeader(
child: CircleAvatar(
backgroundColor: Colors.deepOrange,
radius: 100,
child: Image(
fit: BoxFit.cover,
image: NetworkImage(
img != null ? img : Container(), // <== here
) ??
CircularProgressIndicator(),
),
),
decoration: BoxDecoration(
color: Colors.orange,
),
),
【问题讨论】: