fix: use ValueKey<String> for reorderable grid and add status bar padding

flutter_reorderable_grid_view requires String keys, not int. Also
adds safe area top padding so the room grid doesn't overlap the
system status bar.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-15 22:59:24 +01:00
parent 98f42ccb9c
commit 76cd98300d
4 changed files with 15 additions and 14 deletions

View File

@@ -123,7 +123,7 @@ class _RoomGridState extends ConsumerState<_RoomGrid> {
final l10n = AppLocalizations.of(context);
final children = widget.rooms.map((rws) {
return RoomCard(
key: ValueKey(rws.room.id),
key: ValueKey('room-${rws.room.id}'),
roomWithStats: rws,
onEdit: () => context.go('/rooms/${rws.room.id}/edit'),
onDelete: () => _showDeleteConfirmation(context, rws, l10n),
@@ -134,17 +134,19 @@ class _RoomGridState extends ConsumerState<_RoomGrid> {
scrollController: _scrollController,
onReorder: (ReorderedListFunction<Widget> reorderFunc) {
final reordered = reorderFunc(children);
final newOrder = reordered
.map((w) => (w.key! as ValueKey<int>).value)
.toList();
final newOrder = reordered.map((w) {
final keyStr = (w.key! as ValueKey<String>).value;
return int.parse(keyStr.replaceFirst('room-', ''));
}).toList();
ref.read(roomActionsProvider.notifier).reorderRooms(newOrder);
},
builder: (reorderableChildren) {
final topPadding = MediaQuery.of(context).padding.top;
return GridView.count(
key: _gridViewKey,
controller: _scrollController,
crossAxisCount: 2,
padding: const EdgeInsets.all(12),
padding: EdgeInsets.fromLTRB(12, 12 + topPadding, 12, 12),
mainAxisSpacing: 8,
crossAxisSpacing: 8,
childAspectRatio: 1.0,