我想用索引值从1到n重复以下代码。如何在颤抖中做到这一点?
return ListView(
children: <Widget>[
SizedBox(
height: 15.0,
),
new Image.asset(
"assets/$name/$index.jpg",
fit: BoxFit.cover,
),
SizedBox(
height: 10.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("$name $index",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 23,
fontFamily: 'Raleway',
color: Colors.black)),
Container(
margin: EdgeInsets.only(left: 100.0),
width: 150.0,
height: 50.0,
child: FlatButton(
onPressed: null,
child: Text('Download',
style: TextStyle(color: Colors.black, fontSize: 20)),
textColor: Colors.white,
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.teal, width: 2, style: BorderStyle.solid),
borderRadius: BorderRadius.circular(50)),
),
),
],
),
],
);
答案 0 :(得分:0)
使用while循环显示3次简单文本。
Widget getWidgets() {
List<Widget> list = new List<Widget>();
int i = 0;
while (i < 3) {
list.add(new Text(strings[i]));
i++;
}
return Row(children:list);
}
答案 1 :(得分:0)