Get rid of that stinky ass weird ass grid sliver

This commit is contained in:
2025-02-22 15:22:49 +01:00
parent 362dea6b08
commit c94a8f8926

View File

@@ -80,42 +80,43 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
body: RefreshIndicator( body: RefreshIndicator(
onRefresh: _refreshGames, onRefresh: _refreshGames,
child: GridView.builder( child: SingleChildScrollView(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( child: Wrap(
crossAxisCount: 3, spacing: 4,
childAspectRatio: 1.3, runSpacing: 4,
crossAxisSpacing: 4, children: [
mainAxisSpacing: 4, ...games.map((game) => SizedBox(
width: 400,
child: GameCard(
game: game,
onGameUpdated: (game) async {
game = await GameRepository.upsert(game);
setState(() {
games[games.indexOf(game)] = game;
});
},
onDelete: () async {
await GameRepository.delete(game);
setState(() {
games.remove(game);
});
},
), ),
itemCount: games.length + 1, // +1 for the new game card )),
itemBuilder: (context, index) { SizedBox(
if (index == games.length) { width: 400,
return NewGameCard( child: NewGameCard(
onGameCreated: (game) async { onGameCreated: (game) async {
game = await GameRepository.upsert(game); game = await GameRepository.upsert(game);
setState(() { setState(() {
games.add(game); games.add(game);
}); });
}, },
); ),
} ),
return GameCard( ],
game: games[index], ),
onGameUpdated: (game) async {
game = await GameRepository.upsert(game);
setState(() {
games[index] = game;
});
},
onDelete: () async {
await GameRepository.delete(games[index]);
setState(() {
games.removeAt(index);
});
},
);
},
), ),
), ),
); );