[Flutter]GridView

小黑
發佈於APP
2023/12/19閱讀時間約 1 分鐘

下面代碼為兩列的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前面是長度, 後面是要放入一個方法。

7會員
78內容數
嗨,我是一名程式設計師,會在這分享開發與學習紀錄。
留言0
查看全部
發表第一個留言支持創作者!
從 Google News 追蹤更多 vocus 的最新精選內容