| | |
| | | } |
| | | return Padding( |
| | | padding: const EdgeInsets.symmetric(horizontal: 70), |
| | | child: GridView.builder( |
| | | shrinkWrap: true, |
| | | physics: const NeverScrollableScrollPhysics(), |
| | | gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( |
| | | crossAxisCount: 4, |
| | | mainAxisSpacing: 18, |
| | | crossAxisSpacing: 16, |
| | | childAspectRatio: 0.62, |
| | | ), |
| | | itemCount: games.length, |
| | | itemBuilder: (context, i) => GameCard(game: games[i]), |
| | | ), |
| | | child: LayoutBuilder(builder: (context, constraints) { |
| | | // 卡片高度 = 封面高度 + 信息区实际内容高度,避免信息区出现大段空白 |
| | | const crossAxisSpacing = 16.0; |
| | | final cardWidth = |
| | | (constraints.maxWidth - crossAxisSpacing * 3) / 4; |
| | | final coverHeight = cardWidth / 1.42; // 与 GameCard 封面 AspectRatio 一致 |
| | | const infoHeight = 96.0; // 版本行 + 标题两行 + 类别/添加按钮行 + 内边距 |
| | | return GridView.builder( |
| | | shrinkWrap: true, |
| | | physics: const NeverScrollableScrollPhysics(), |
| | | gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
| | | crossAxisCount: 4, |
| | | mainAxisSpacing: 18, |
| | | crossAxisSpacing: crossAxisSpacing, |
| | | mainAxisExtent: coverHeight + infoHeight, |
| | | ), |
| | | itemCount: games.length, |
| | | itemBuilder: (context, i) => GameCard(game: games[i]), |
| | | ); |
| | | }), |
| | | ); |
| | | } |
| | | |