下面代碼為兩列的GridView
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new GridView.count(
crossAxisCount: 2,
children: new List.generate(20, (index) {
return new Center(
child: new Text(
'$index',
),
);
}),
);
}
}
crossAxisCount為要顯示的列數;List.generate前面是長度, 後面是要放入一個方法。