期望一个类型为 "imageProvider<object>" 的值,但得到了类型"_HashSet<AssetImage>">"之一



我想通过使用for循环和获取变量长度来实现这一目标

height: 200.0,
child: new Carousel(
boxFit: BoxFit.cover,
//Start problem Area
images: [
for (int i = 0; i < widget.eoprod_slider.length; i++)
{AssetImage(widget.eoprod_slider[i])}
],//End Problem Area
autoplay: false,
dotSize: 4.0,
indicatorBgPadding: 2.0,
),
);

将它们映射到一个列表中,并按原样传递:

height: 200.0,
child: new Carousel(
boxFit: BoxFit.cover,
//Start problem Area
images: widget.eoprod_slider.map((e)=>AssetImage(e)).toList(),
//End Problem Area
autoplay: false,
animationCurve: Curves.fastOutSlowIn,
animationDuration: Duration(milliseconds: 1000),
dotSize: 4.0,
indicatorBgPadding: 2.0,
),
);

相关内容

最新更新