feat: enhance admin and profile repositories with token handling; update dropdown initial values in various screens

This commit is contained in:
Nils-Johan Gynther
2026-04-23 21:34:08 +02:00
parent 111d196403
commit b589f7415d
15 changed files with 63 additions and 36 deletions
@@ -19,6 +19,10 @@ class _StringNotifier extends Notifier<String> {
final String _initial;
@override
String build() => _initial;
void setValue(String value) {
state = value;
}
}
final inventoryLocationFilterProvider =
@@ -196,7 +196,7 @@ class _CreateInventoryScreenState
const SizedBox(width: 8),
Expanded(
child: DropdownButtonFormField<String>(
value: _unitController.text.trim().isEmpty
initialValue: _unitController.text.trim().isEmpty
? null
: _unitController.text.trim(),
isExpanded: true,
@@ -224,7 +224,7 @@ class _CreateInventoryScreenState
),
const SizedBox(height: 12),
DropdownButtonFormField<String>(
value: _locationController.text.trim().isEmpty
initialValue: _locationController.text.trim().isEmpty
? null
: _locationController.text.trim(),
isExpanded: true,
@@ -175,7 +175,7 @@ class _InventoryEditScreenState extends ConsumerState<InventoryEditScreen> {
const SizedBox(width: 8),
Expanded(
child: DropdownButtonFormField<String>(
value: _unitController.text.trim().isEmpty
initialValue: _unitController.text.trim().isEmpty
? null
: _unitController.text.trim(),
isExpanded: true,
@@ -204,7 +204,7 @@ class _InventoryEditScreenState extends ConsumerState<InventoryEditScreen> {
),
const SizedBox(height: 12),
DropdownButtonFormField<String>(
value: _locationController.text.trim().isEmpty
initialValue: _locationController.text.trim().isEmpty
? null
: _locationController.text.trim(),
isExpanded: true,
@@ -4,9 +4,7 @@ import 'package:go_router/go_router.dart';
import '../../../core/api/api_error_mapper.dart';
import '../../../core/ui/async_state_views.dart';
import '../../auth/data/auth_providers.dart';
import '../data/inventory_providers.dart';
import '../domain/inventory_item.dart';
import 'swipeable_inventory_tile.dart';
class InventoryScreen extends ConsumerWidget {
@@ -53,14 +51,14 @@ class InventoryScreen extends ConsumerWidget {
selected: location == option,
onSelected: (_) => ref
.read(inventoryLocationFilterProvider.notifier)
.state = option,
.setValue(option),
),
)
.toList(),
),
const SizedBox(height: 8),
DropdownButtonFormField<String>(
value: sort,
initialValue: sort,
isExpanded: true,
decoration: const InputDecoration(
labelText: 'Sortering',
@@ -75,8 +73,9 @@ class InventoryScreen extends ConsumerWidget {
)
.toList(),
onChanged: (value) {
ref.read(inventorySortFilterProvider.notifier).state =
value ?? '';
ref
.read(inventorySortFilterProvider.notifier)
.setValue(value ?? '');
},
),
],