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