1.
List<Container> _buildGridTileList(int count) => List.generate(
count,
(i) => Container(
child: Image.asset('images/pic$i.jpg')
)
);
Widget _buildGrid() => GridView.extent(
maxCrossAxisExtent: 150.0,
padding: const EdgeInsets.all(4.0),
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
children: _buildGridTileList(30)
);
return
_buildGrid();
pubspec.yaml assets:
[images/]
1-1. padding是最外圍的內距
1-2. mainAxisSpacing是上下間距
1-3. crossAxisSpacing是左右間距
1-4. maxCrossAxisExtent是75時,有4欄6列多;50時,有6欄5列(其實就是一個項目寬度75像素或50像素)
沒有留言:
張貼留言