I want to loop some part of function base on widget.menuItem.category.length, I am new in flutter. Here is my current code :
_buildContentView({BuildContext context}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
_buildMenuItemImage(),
Container(
child: Text(widget.menuItem.name,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
padding: EdgeInsets.only(left: 16, right: 16, top: 12, bottom: 8),
),
Container(
child: Text(widget.menuItem.itemDescription,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.normal)),
padding: EdgeInsets.only(left: 16, right: 16, top: 12, bottom: 8),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Text( Select + widget.menuItem.category[0]),
padding: EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 6),
),
Container(
child: Text( Select +
_qty.toString() +
item ( +
_qty.toString() +
/ +
widget.menuItem.setMenuItems.length.toString() +
) ),
padding: EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 6),
),
],
),
_buildSetMenusView(setMenuItems: widget.menuItem.setMenuItems),
Padding(
padding: EdgeInsets.only(left: 12, right: 12, top: 8, bottom: 12),
child: _buildActionButtons(context: context),
)
],
);
}
我想谈谈这一部分:
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Text( Select + widget.menuItem.category[0]),
padding: EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 6),
),
Container(
child: Text( Select +
_qty.toString() +
item ( +
_qty.toString() +
/ +
widget.menuItem.setMenuItems.length.toString() +
) ),
padding: EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 6),
),
],
),
_buildSetMenusView(setMenuItems: widget.menuItem.setMenuItems),
我尝试了这一法典,但没有成功。
for(var i = 0; i < widget.menuItem.category.length; i++){
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Text( Select + widget.menuItem.category[i]),
padding: EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 6),
),
Container(
child: Text( Select +
_qty.toString() +
item ( +
_qty.toString() +
/ +
widget.menuItem.setMenuItems.length.toString() +
) ),
padding: EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 6),
),
],
),
_buildSetMenusView(setMenuItems: widget.menuItem.setMenuItems),
}
哪一部正确的法典能够把这一部分放在冲碎中? 请帮助我修复这一冲破碎的隔op。