【发布时间】:2021-12-23 06:32:08
【问题描述】:
错误:“参数类型 'Breakfast' 不能分配给参数类型 String。dart argument_type_not_assignable 早餐配料”。我不知道如何查看列表中的列表。
class BreakfastIngredient extends StatefulWidget {
const BreakfastIngredient({
Key? key,
required this.breakfast,
}) : super(key: key);
final Breakfast breakfast;
@override
_BreakfastIngredientState createState() => _BreakfastIngredientState();
}
class _BreakfastIngredientState extends State<BreakfastIngredient> {
late List ingredients;
@override
Widget build (BuildContext context) {
return Row(
children: breakfastProducts.map((ingredients){
return Text(ingredients);
}
).toList()
);
}
}
'我正在尝试从此列表中获取数据'。我想从“配料”中获取数据。
List<Breakfast> breakfastProducts = [
Breakfast(
id: 1,
images: [
"assets/images/cilantro.png",
],
title: "Cilantro and Kale Pesto Toast with a Fried Egg",
time: 15,
description: "Sliced bread is the perfect blank canvas, ready to be loaded up with virtuous ingredients.",
rating: 4.8,
isFavourite: true,
isPopular: true,
ingredients: [
"¼ cup packed cilantro",
"1 cup packed kale leaves",
"¼ cup extra-virgin olive oil",
"1 tablespoon white balsamic vinegar",
"2 tablespoons hulled hemp seeds*",
"salt",
"Freshly ground pepper",
"1 large slice of whole-wheat toast",
"2 tablespoons unflavored whole-milk Greek yogurt",
"1 fried egg",
],
procedure: "procedure",
),
];
【问题讨论】: