使用Canvaskit flutter Web构建:无法加载image.network()
我无法使用来自域中的图像URL,但是可以使用像Facebook这样的另一个域中的图像URL。错误是:
当将image.network()中的stackoverflow放置图像URL时,它也会发生。例如,尝试使用上面的图片(image.network('https://i.sstatic.net/o6lwe.png')
)。
使用HTML(flutter Run -d Chrome -web -Renderer HTML
)渲染了修复的基本方法,但我需要使用toimage()函数并使用HTML渲染不支持此功能。所以我用拿桌渲染。
此链接( https://docs.flutter.dev/development/platform-integration/web-images#host-your-images-images-in-a-cors-enabled-cdn )可以帮助使用firebase的人,但我我正在将Ubuntu与Apache一起使用。
实际上,我想使用HTML渲染,因为在使用Canvaskit渲染后,我遇到了很多问题。
使用HTML情况渲染:如果可以使用一个函数代替toimage()函数,请告诉我。
使用Canvaskit情况渲染:如果您知道如何使用image.network()显示图像URL,请告诉我。
谢谢。
I can't use the image URL from my domain but I can use the image URL from another domain like Facebook. The error is:
It happened when putting the image URL from StackOverflow in the Image.network() too. For example, try using the picture above(Image.network('https://i.sstatic.net/o6lwE.png')
).
The basic method for fixing is rendered with HTML(flutter run -d chrome --web-renderer html
) but I need to use the toImage() function and rendering with HTML doesn't support this function. So I render with Canvaskit.
This link(https://docs.flutter.dev/development/platform-integration/web-images#host-your-images-in-a-cors-enabled-cdn) can help someone who is using the Firebase but I am using the Ubuntu with the Apache.
Actually, I want to render with HTML because after rendering with Canvaskit I encountered a lot of problems.
Render with HTML case: If there is a function that can be used instead of the toImage() function, please tell me.
Render with Canvaskit case: If you know how to display the image URL with Image.network(), please tell me.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题是由stackoverflow的自动系统关闭的,因此我将其删除并创建一个新的问题。
两天后,这就是我发现的。
https://cors-anywhere.herokuapp.com/
或创建代理。单击 https://cors-anywhere.herokuapp.com/ 并激活它。<<<<<<<<<<<<<<<<<<<<<<<< /p>
您的图像小部件看起来像这样:
image.network('https://cors-anywhere.herokuapp.com/jumageurl')
initstate()
或widget build()
中添加此之前,必须在 - 您的映像窗口小部件如下:&lt; directory/directory/var/www/www/&gt;
标签激活的.htacess by Open/etc/apache2/apache2/apache2.conf
到AllowOverride所有
。使用
a2enmod标头启用mod_headers
然后使用
sudo服务apache2 restart
重新启动apache。我认为:
..样式。 *最长 *
是'100%'
,较短的侧面是'auto'
。拥有一个完成方法2之类的软件包会很高兴。
您可以尝试以下位置。
https://flutter-test-test-exam-exam-bug.web.web.app/#/ stackoverflow_72306043
用于在本地方面进行测试 flutter web(Canvaskit),请关注
This question was closed by the auto system of StackOverflow, So I delete it and create a new one.
After 2 days, that's what I found.
https://cors-anywhere.herokuapp.com/
or create your proxy.click https://cors-anywhere.herokuapp.com/ and activate it.
Your image widget looks like this:
Image.network('https://cors-anywhere.herokuapp.com/$imageUrl')
initState()
orWidget build()
, this has to use before - Your image widget looks like this:/etc/apache2/apache2.conf
in<Directory /var/www/>
tag, changeAllowOverride None
toAllowOverride All
.Enable mod_headers with
a2enmod headers
thenrestart apache with
sudo service apache2 restart
.In my opinion:
..style. *longest *
is'100%'
and the shorter side is'auto'
.It would be nice to have a package that completes things like method 2.
You can try your imageUrl at:
https://flutter-test-exam-bug.web.app/#/stackoverflow_72306043
For testing on the local side for the Flutter web (Canvaskit), follow this
我正在为Web使用Canvaskit渲染。当试图通过URL显示图像时:
我得到错误:抛出了另一个例外:[object progressevent]
我解决了来自pub.dev的软件包的问题: image_network
我的解决方案:
I'm using canvaskit rendering for web. When trying to display an image by url:
I get the error: Another exception was thrown: [object ProgressEvent]
I solved the problem with the package from pub.dev: image_network
My solution: