无法使用Flutter 翼在FireBase中预览我的图像...
这是我的Firebase控制台屏幕截图.
以下是图库中的图像拾取器服务的代码
Future<File?> getImageFromGallery() async {
final pickedFile = await _picker.pickImage(source: ImageSource.gallery);
if (pickedFile != null) {
image = File(pickedFile.path);
return image;
} else {
Fluttertoast.showToast(msg: 'Error , No Image Selected');
return null;
}
}
使用事件获取文件,然后上载到Firebase存储:
on<SubmitUserFormDataEvent>((event, emit) async {
emit(UserFormLoadingState());
// uploading the picture to firebase storage & get url
File file = event.profile_image_file;
String baseName = file.path.split('/').last;
Reference ref = FirebaseStorage.instance
.ref()
.child("profile_images/$baseName"); //generate a unique name
await ref.putFile(file);
String imageUrl = await ref.getDownloadURL();
print(imageUrl);
它已成功上载到Firebase并获取下载URL.如果我点击Chrome中的下载URL,它会自动启动Downlaod,但图像不会显示.这不是我不能将其展示给用户界面的原因.
正在获取下载URL,我无法将图像显示到用户界面.我想像这样预览我的形象.我怎么能做到这一点?