出錯(cuò)提示:
Failed to load network image.
Image URL: https://tva1.sinaimg.cn/large/006y8mN6gy1g72j6nk1d4j30u00k0n0j.jpg
Trying to load an image from another domain? Find answers at:
圖片資源跨域問(wèn)題詳細(xì)解釋可以去官方查看官方解釋
這里給出解決方式的一種:
Image(image: NetworkImage("https://tva1.sinaimg.cn/large/006y8mN6gy1g72j6nk1d4j30u00k0n0j.jpg"),
fit: BoxFit.cover,
),
替代方式之一:
class MyImage extends StatelessWidget {
@override
Widget build(BuildContext context) {
String imageUrl = "https://tva1.sinaimg.cn/large/006y8mN6gy1g72j6nk1d4j30u00k0n0j.jpg";
// https://github.com/flutter/flutter/issues/41563
// ignore: undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory(
imageUrl,
(int _) => ImageElement()..src = imageUrl,
);
return HtmlElementView(
viewType: imageUrl,
);
}
}