我正在将产品卡片列表从产品小部件返回到父类。我认为此处的类型推断失败,但是我找不到解决方法。
return Column(
children: _products
.map((element) => Card(
color: Colors.pink,
child: Column(
children: <Widget>[
Image.asset(element.path),
Text(element.text)
],
)))
.toList(),
);
}
答案 0 :(得分:0)
尝试使用此:
return Column(
children: List<Widget>.from(_products
.map((element) => Card(
color: Colors.pink,
child: Column(
children: <Widget>[
Image.asset(element.path),
Text(element.text)
],
)))
.toList()),
);