/**
* images 图片数组
* titles title数组
* length_w 一行的数量
* length_h 行数
*/
static Widget getMenuGrade(
List<String> images, List<String> titles, int length_w, int length_h) {
int startIndex = 0;
List<Widget> rowList = [];
List<List<Widget>> columList = [];
List<Widget> allList = [];
for (int b = 0; b < length_h; b++) {
for (int a = startIndex; a < startIndex + length_w; a++) {
rowList.add(Expanded(
child: Container(
child: Column(
children: [
Image.asset(
images[a],
height: 35,
),
SizedBox(height: 5,),
Text(
titles[a],
style: TextStyle(fontSize: 12, color: PublicColors.textcolor2),
)
],
),
)));
}
columList.add(rowList);
rowList = [];
startIndex = length_w * (b + 1);
}
for (int c = 0; c < columList.length; c++) {
allList.add(Container(
margin: EdgeInsets.fromLTRB(0, 15, 0, 0),
child: Row(
children: columList[c],
)));
}
return Container(
margin: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: Column(
children: allList,
),
);
}
效果: