常用GridView.count:
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: Text('我是首页'),
),
body: new SafeArea(
child: new GridView.count(
primary: false,
scrollDirection: Axis.vertical,
crossAxisCount: 2, // 横向item个数
padding: const EdgeInsets.all(5.0), // 内边距
crossAxisSpacing: 10.0, // 横向间距
mainAxisSpacing: 10.0, // 竖向间距
children: <Widget>[
new Image.asset('images/11.png', fit: BoxFit.fill,),
new Image.asset('images/22.png', fit: BoxFit.fill,),
new Image.asset('images/22.png', fit: BoxFit.fill,),
new Image.asset('images/11.png', fit: BoxFit.fill,),
new Image.asset('images/22.png', fit: BoxFit.fill,),
new Image.asset('images/11.png', fit: BoxFit.fill,),
new Image.asset('images/11.png', fit: BoxFit.fill,),
new Image.asset('images/22.png', fit: BoxFit.fill,),
new Image.asset('images/11.png', fit: BoxFit.fill,),
new Image.asset('images/22.png', fit: BoxFit.fill,),
new Image.asset('images/22.png', fit: BoxFit.fill,),
new Image.asset('images/11.png', fit: BoxFit.fill,),
new Image.asset('images/22.png', fit: BoxFit.fill,),
new Image.asset('images/11.png', fit: BoxFit.fill,),
new Image.asset('images/11.png', fit: BoxFit.fill,),
new Image.asset('images/22.png', fit: BoxFit.fill,),
],
),
),
);
}
}
竖屏:
横屏: