我正试图从firebase存储中的文件夹加载图像,代码给了我这个错误{类型'Future'不是类型'String'的子类型}我甚至不知道这段代码是否达到了我的目的
class FireStorageService extends ChangeNotifier{
FireStorageService();
final storage = FirebaseStorage.instance;
static Future<dynamic> loadImage(String image) async{
return await storage.ref('folder5/$image').getDownloadURL();
}
}
Future<Widget> getImage() async {
final url = await FireStorageService.loadImage('1.jpg');
return Image.network(url);
}
从loadImage
函数返回Future<String>
:
class FireStorageService extends ChangeNotifier{
FireStorageService();
static Future<String> loadImage(String image) async {
return await FirebaseStorage.instance.ref('folder5/$image').getDownloadURL();
}
}
Future<Widget> getImage() async {
final url = await FireStorageService.loadImage('1.jpg');
return Image.network(url);
}