Fix up the grid agin

This commit is contained in:
2025-02-22 15:51:53 +01:00
parent edb7dbfe05
commit 406be305e2

View File

@@ -80,15 +80,18 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
body: RefreshIndicator( body: RefreshIndicator(
onRefresh: _refreshGames, onRefresh: _refreshGames,
child: SingleChildScrollView( child: LayoutBuilder(
builder: (context, constraints) {
final cardWidth = constraints.maxWidth / 4;
return SingleChildScrollView(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Wrap( child: Wrap(
spacing: 4, spacing: 8,
runSpacing: 4, runSpacing: 8,
children: [ children: [
...games.values.map( ...games.values.map(
(game) => SizedBox( (game) => SizedBox(
width: 400, width: cardWidth - 10, // Subtract spacing to fit 4 cards
child: GameCard( child: GameCard(
game: game, game: game,
onGameUpdated: (game) async { onGameUpdated: (game) async {
@@ -107,7 +110,7 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
), ),
SizedBox( SizedBox(
width: 400, width: cardWidth - 10, // Subtract spacing to fit 4 cards
child: NewGameCard( child: NewGameCard(
onGameCreated: (game) async { onGameCreated: (game) async {
game = await GameRepository.upsert(game); game = await GameRepository.upsert(game);
@@ -119,6 +122,8 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
], ],
), ),
);
},
), ),
), ),
); );