Get rid of that stinky ass weird ass grid sliver
This commit is contained in:
@@ -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);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
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);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user