我有一個名為 Src 的影像 url 串列。我想通過這個包顯示這些影像:https : //pub.dev/packages/flutter_image_slideshow。但是什么時候這樣做:
Container(
width: pageWidth,
height: pageHeight / 2.5,
// color: Colors.red,
child: ImageSlideshow(
children: [
CachedNetworkImage(
imageUrl: src,
),
],
)
);
控制臺 說:
type 'List<String>' is not a subtype of type 'String'
也當我將我的串列轉換為這樣的字串時:
CachedNetworkImage(
imageUrl: src.toString().replaceAll("[", "").replaceAll("]", ""),
),
控制臺 說:
I/flutter ( 4859): CacheManager: Failed to download file from https://ahmadihypermarket.com/ext/uploads/2021/11/1-378.jpg, https://ahmadihypermarket.com/ext/uploads/2021/11/2-290.jpg with error:
I/flutter ( 4859): HttpException: Invalid statusCode: 404, uri = https://ahmadihypermarket.com/ext/uploads/2021/11/1-378.jpg, https://ahmadihypermarket.com/ext/uploads/2021/11/2-290.jpg
有人知道如何修復它并顯示影像嗎?
uj5u.com熱心網友回復:
試試下面的代碼
Container(
width: pageWidth,
height: pageHeight / 2.5,
// color: Colors.red,
child: ImageSlideshow(
children:List<Widget>.generate(
src.length,
(index) {
return CachedNetworkImage(
imageUrl: src[index],
);
},
),
)
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/374342.html
上一篇:如何對角地乘以串列的元素?
