diff --git a/lib/main.dart b/lib/main.dart index e952c6a..35d2ac1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -80,42 +80,43 @@ class _MyHomePageState extends State { ), body: RefreshIndicator( onRefresh: _refreshGames, - child: GridView.builder( + child: SingleChildScrollView( padding: const EdgeInsets.all(8), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, - childAspectRatio: 1.3, - crossAxisSpacing: 4, - mainAxisSpacing: 4, + child: Wrap( + spacing: 4, + runSpacing: 4, + children: [ + ...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); + }); + }, + ), + )), + SizedBox( + width: 400, + child: NewGameCard( + onGameCreated: (game) async { + game = await GameRepository.upsert(game); + setState(() { + games.add(game); + }); + }, + ), + ), + ], ), - itemCount: games.length + 1, // +1 for the new game card - itemBuilder: (context, index) { - if (index == games.length) { - return NewGameCard( - onGameCreated: (game) async { - game = await GameRepository.upsert(game); - setState(() { - 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); - }); - }, - ); - }, ), ), );