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,45 +80,50 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
body: RefreshIndicator( body: RefreshIndicator(
onRefresh: _refreshGames, onRefresh: _refreshGames,
child: SingleChildScrollView( child: LayoutBuilder(
padding: const EdgeInsets.all(8), builder: (context, constraints) {
child: Wrap( final cardWidth = constraints.maxWidth / 4;
spacing: 4, return SingleChildScrollView(
runSpacing: 4, padding: const EdgeInsets.all(8),
children: [ child: Wrap(
...games.values.map( spacing: 8,
(game) => SizedBox( runSpacing: 8,
width: 400, children: [
child: GameCard( ...games.values.map(
game: game, (game) => SizedBox(
onGameUpdated: (game) async { width: cardWidth - 10, // Subtract spacing to fit 4 cards
game = await GameRepository.upsert(game); child: GameCard(
setState(() { game: game,
games[game.name] = game; onGameUpdated: (game) async {
}); game = await GameRepository.upsert(game);
}, setState(() {
onDelete: () async { games[game.name] = game;
await GameRepository.delete(game); });
setState(() { },
games.remove(game.name); onDelete: () async {
}); await GameRepository.delete(game);
}, setState(() {
games.remove(game.name);
});
},
),
),
), ),
), SizedBox(
width: cardWidth - 10, // Subtract spacing to fit 4 cards
child: NewGameCard(
onGameCreated: (game) async {
game = await GameRepository.upsert(game);
setState(() {
games[game.name] = game;
});
},
),
),
],
), ),
SizedBox( );
width: 400, },
child: NewGameCard(
onGameCreated: (game) async {
game = await GameRepository.upsert(game);
setState(() {
games[game.name] = game;
});
},
),
),
],
),
), ),
), ),
); );