Flutter Web不显示来自Firebase存储的NetworkImages,但在android模拟器上工作完美.&



如标题所示,我正在将我的应用程序部署到Flutter Web,我正在显示来自Firebase存储的图片。当在android模拟器上测试时,它工作完美,显示所有图像没有错误。然而,当我将它部署到我的web应用程序时,由于某种原因,图像根本不显示。下面我添加了相关的代码片段,它显示了我如何显示来自Firebase的图片(再次,在Android模拟器上工作得非常好)以及当它试图显示图片时web应用程序上的错误。

代码:

void checkImages() async {
FirebaseFirestore.instance
.collection("uploads")
.where('username', isEqualTo: Constants.myName)
.get()
.then((querySnapshot) {
querySnapshot.docs.forEach((result) {
FirebaseFirestore.instance
.collection("uploads")
.doc(result.id)
.collection("images")
.get()
.then((querySnapshot) {
querySnapshot.docs.forEach((result) async {
imageCount++;
final ref =
FirebaseStorage.instance.ref().child(result.data()['imageid']);
url = await ref.getDownloadURL();
setState(() {
printImages();
});
});
});
});
});
}
printImages() {
return List.generate(imageCount, (index) {
return GestureDetector(
onTap: () {
print( "hello");
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
child: Image.network(
url.toString(),
fit: BoxFit.cover,
),
),
);
});
} 

web控制台错误:

main.dart.js?version=19:3082 Uncaught MissingPluginException(No implementation found for method StorageReference#getDownloadUrl on channel plugins.flutter.io/firebase_storage)
at Object.a (https://social-io-102b4.firebaseapp.com/main.dart.js?version=19:3082:3)
at https://social-io-102b4.firebaseapp.com/main.dart.js?version=19:53813:15
at adv.a (https://social-io-102b4.firebaseapp.com/main.dart.js?version=19:4517:71)
at adv.$2 (https://social-io-102b4.firebaseapp.com/main.dart.js?version=19:30063:23)
at acI.$1 (https://social-io-102b4.firebaseapp.com/main.dart.js?version=19:30055:30)
at No.mY (https://social-io-102b4.firebaseapp.com/main.dart.js?version=19:31072:40)
at a82.$0 (https://social-io-102b4.firebaseapp.com/main.dart.js?version=19:30474:11)
at Object.rs (https://social-io-102b4.firebaseapp.com/main.dart.js?version=19:4637:40)
at a1.nL (https://social-io-102b4.firebaseapp.com/main.dart.js?version=19:30390:3)
at a7V.$0 (https://social-io-102b4.firebaseapp.com/main.dart.js?version=19:30432:22)

为了补充这一点,我很确定我已经正确安装了所有插件,因为它在Android上工作。如有任何帮助,我将不胜感激,谢谢。

请尝试添加这个脚本标签在你用Firebase凭证(当你在Firebase中添加一个新的web应用程序时得到它们)初始化index.html之后,

//import the Firestore plugin
<script src="https://www.gstatic.com/firebasejs/8.2.10/firebase-firestore.js"></script>

看看这个网站,看看你可能想要导入的所有插件:

https://firebase.google.com/docs/web/setup expandable-8

相关内容