[英](FLUTTER) Getting error while trying to display a network image whose URL I am getting as an argument from the previous screen
My first screen is using the same image and I am not facing any issue there but when I go to the second screen and wanna use the same image, I am getting "Invalid argument(s): No host specified in URI file:///Instance%20of%20'Future%3Cdynamic%3E'".我的第一个屏幕使用相同的图像,我在那里没有遇到任何问题,但是当我 go 到第二个屏幕并想使用相同的图像时,我得到“无效参数:URI 文件中指定的主机:// /Instance%20of%20'Future%3Cdynamic%3E'"。 I tried Urifullencode and made sure that the URL of the image has https:// in it but it is still not working for some reason
我尝试了 Urifullencode 并确保图像的 URL 中有 https:// 但由于某种原因它仍然无法正常工作
here is the code:这是代码:
getImageUrl() async {
var image = await Get.arguments['imageUrl'];
if (image == null){
return 'https://miro.medium.com/max/880/0*H3jZONKqRuAAeHnG.jpg';
}
else{
return image;
}
}
following is the widget in which I am using the above function以下是我使用上述 function 的小部件
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.network(
Uri.encodeFull(getImageUrl().toString()),
),
),
And lastly the error:最后是错误:
════════ Exception caught by image resource service ════════════════════════════ ════════ 图片资源服务捕获的异常════════════════════════════
The following ArgumentError was thrown resolving an image codec: Invalid argument(s): No host specified in URI file:///Instance%20of%20'Future%3Cdynamic%3E'解析图像编解码器时引发以下 ArgumentError:无效参数:URI 文件中未指定主机:///Instance%20of%20'Future%3Cdynamic%3E'
I still get the same error even if I remove async-await, and in my emulator as soon as I navigate to the second screen, everything works well except the container that is holding the network image (it displays a crossed-out image of the same error message).即使我删除了 async-await,我仍然会遇到同样的错误,并且在我的模拟器中,一旦我导航到第二个屏幕,除了保存网络图像的容器(它显示一个划掉的图像相同的错误信息)。
ah sorry, silly mistake on my part.啊对不起,我犯了一个愚蠢的错误。 The screen from where I was getting the arguments had a spelling mistake in one of the argument variables.
我从中获取 arguments 的屏幕在其中一个参数变量中有拼写错误。 Fixed it, its working now.
修复它,它现在工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.