Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 如何从项目列表中访问图像?_List_Flutter_Dart - Fatal编程技术网

List 如何从项目列表中访问图像?

List 如何从项目列表中访问图像?,list,flutter,dart,List,Flutter,Dart,我有一个文本和图像的混合列表,我想把适用的文本和图像一起放在一张卡片上。当前代码适用于文本,但是,当我尝试添加图像时,总是会出现错误。有人知道怎么做吗 感谢您的帮助 class Episode { String seasonEpisode; String airDate; Image epImage; Episode({this.seasonEpisode, this.airDate, this.epImage}); } 类eposodelist扩展StatefulWidg

我有一个文本和图像的混合列表,我想把适用的文本和图像一起放在一张卡片上。当前代码适用于文本,但是,当我尝试添加图像时,总是会出现错误。有人知道怎么做吗

感谢您的帮助

class Episode {
  String seasonEpisode;
  String airDate;
  Image epImage;

  Episode({this.seasonEpisode, this.airDate, this.epImage});
}

类eposodelist扩展StatefulWidget{
/*最后一集*/
@凌驾
_EpiodeListState createState()=>_EpiodeListState();
}
类_eposodeListState扩展状态{
列表集=[
插曲(季节插曲:“S24:E1”,播出日期:“2020年2月18日”,epImage:Image.asset('assets/Bachelor1.jpeg'),
插曲(季节插曲:“S24:E2”,播出日期:“2020年2月25日”,epImage:Image.asset('assets/Bachelor1.jpeg')),
插曲(季节插曲:“S24:E3”,播出日期:“2020年2月31日”,epImage:Image.asset('assets/Bachelor1.jpeg')),
];
小部件epCardTemplate(插曲){
回程卡(
边距:LTRB(16.0,16.0,16.0,0.0)的常数边集,
子:列(
crossAxisAlignment:crossAxisAlignment.stretch,
儿童:[
Image.asset(插曲.epImage),
正文(
插曲
),
尺寸箱(高度:6.0),
正文(
开播日期
),
],
),
);
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
背景颜色:深灰色,
正文:专栏(
子项:Spices.map((Spices)=>epCardTemplate(Spices)).toList(),
)
);
}
}

因此,您在代码中所做的与

children: <Widget>[
          Image.asset(Image.asset('assets/......')),
          Text(
            episode.seasonEpisode
          ),
          SizedBox(height: 6.0),
          Text(
            episode.airDate
          ),
        ],
儿童:[
Image.asset(Image.asset('assets/…')),
正文(
插曲
),
尺寸箱(高度:6.0),
正文(
开播日期
),
],
基本上,您正在将一个图像放入另一个图像小部件中

children: <Widget>[
          Image.asset(Image.asset('assets/......')),
          Text(
            episode.seasonEpisode
          ),
          SizedBox(height: 6.0),
          Text(
            episode.airDate
          ),
        ],