gpt4 book ai didi

android-studio - 异常:无法在 Flutter 中实例化图像编解码器

转载 作者:行者123 更新时间:2023-12-03 02:42:16 30 4
gpt4 key购买 nike

我正在开发一个小应用程序,它从互联网上获取图像并使用 NetworkImage() 在屏幕上显示它。小部件。我的代码如下所示:

void main() {
runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("I am Rich"),
backgroundColor: Colors.blueGrey[900],
),
backgroundColor: Colors.blueGrey[200],
body: Center(
child: Image(
image: NetworkImage(
'https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.w3schools.com%2Fw3css%2Fw3css_images.asp&psig=AOvVaw2IxwyCZa7VaOiLr2lA9R2d&ust=1584460177773000&source=images&cd=vfe&ved=2ahUKEwjS8NyhrJ_oAhXt7uAKHURADeMQjRx6BAgAEAc'),
),
),
),
));
}

起初似乎有一个 SocketException我试图通过 this answer 解决这个问题通过将代码行放在这里:

menifest.xml ss

现在,当我再次运行模拟器时,它以:
Performing hot restart...
Syncing files to device Android SDK built for x86...
Restarted application in 31,602ms.

════════ Exception caught by image resource service ════════════════════════════════════════════════
The following _Exception was thrown resolving an image codec:
Exception: Could not instantiate image codec.

When the exception was thrown, this was the stack:
#0 _futurize (dart:ui/painting.dart:4304:5)
#1 instantiateImageCodec (dart:ui/painting.dart:1682:10)
#2 PaintingBinding.instantiateImageCodec (package:flutter/src/painting/binding.dart:88:12)
#3 NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:104:20)
<asynchronous suspension>
...
Image provider: NetworkImage("https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.w3schools.com%2Fw3css%2Fw3css_images.asp&psig=AOvVaw2IxwyCZa7VaOiLr2lA9R2d&ust=1584460177773000&source=images&cd=vfe&ved=2ahUKEwjS8NyhrJ_oAhXt7uAKHURADeMQjRx6BAgAEAc", scale: 1.0)
Image key: NetworkImage("https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.w3schools.com%2Fw3css%2Fw3css_images.asp&psig=AOvVaw2IxwyCZa7VaOiLr2lA9R2d&ust=1584460177773000&source=images&cd=vfe&ved=2ahUKEwjS8NyhrJ_oAhXt7uAKHURADeMQjRx6BAgAEAc", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════════════════════════

我在这里错过了什么?

最佳答案

您在网络图片中提供的 url 地址未指向实际图片。尝试像这样改变它

image: NetworkImage('https://www.w3schools.com/w3css/img_lights.jpg')

关于android-studio - 异常:无法在 Flutter 中实例化图像编解码器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60711389/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com