【发布时间】:2019-04-17 09:39:55
【问题描述】:
我想将保存在firebase storage 中的图像显示到一个小部件中,该小部件在我的屏幕上显示profile picture。
目前我能够获得download url,但不确定如何使用将图像显示到小部件中的那个url。这是显示 profile picture UI 的代码,我想用来自 firebase 的图像更新(即在 ClipOval 小部件内)
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Edit Profile'),
actions: <Widget>[
new Center(child: new Text('SAVE')),
],
),
body: new Stack(
children: <Widget>[
Positioned(
width: 410.0,
top: MediaQuery
.of(context)
.size
.height / 25,
child: Column(children: <Widget>[
Container(
child: user.profilePhoto == ""
? Image.asset('icons/default_profile_icon.png',
height: 110.0)
: ClipOval(
child: _imageFile == null ? Image.asset('icons/default_profile_icon.png', height: 110.0,)
:Image.file(_imageFile,fit: BoxFit.cover,
width: 110.0,
height: 110.0,)
),
),
这就是我从firebase storage 获取图像的方式,它返回下载网址:
displayFile(imageFile) async {
String fileName = 'images/profile_pics/' + this.firebaseUser.uid + ".jpeg";
var data = await FirebaseStorage.instance.ref().child(fileName).getData(10000000);
var text = new String.fromCharCodes(data);
return new NetworkImage(text);
}
我是否需要使用NetworkImage 或cached-network-image 或cache_image 小部件来实现这一点?
【问题讨论】:
标签: firebase flutter firebase-storage