- Flutter/Dart (iOS + Android), Riverpod, go_router, i18n via ARB (deutsch) - Feature-Struktur: today, plants, locations, household (V2-Platzhalter), settings - Intervall-Modell: Aufgaben werden aus lastWatered/lastFertilized + Intervall berechnet - In-Memory-Demo-Daten, Firebase-Anbindung folgt im nächsten Block - Doku: Architektur, Firebase-Einrichtung, Forgejo-Git-Hosting Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
34 lines
1 KiB
Dart
34 lines
1 KiB
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||
|
||
import '../domain/plant_location.dart';
|
||
|
||
/// In-Memory-Stellplätze mit Demo-Daten – wird später durch Firestore ersetzt.
|
||
class LocationsNotifier extends Notifier<List<PlantLocation>> {
|
||
@override
|
||
List<PlantLocation> build() {
|
||
return const [
|
||
PlantLocation(id: 'loc-wohnzimmer', name: 'Wohnzimmer'),
|
||
PlantLocation(id: 'loc-schlafzimmer', name: 'Schlafzimmer'),
|
||
PlantLocation(id: 'loc-kueche', name: 'Küche'),
|
||
];
|
||
}
|
||
|
||
void addLocation(String name) {
|
||
final id = 'loc-${DateTime.now().millisecondsSinceEpoch}';
|
||
state = [...state, PlantLocation(id: id, name: name)];
|
||
}
|
||
}
|
||
|
||
final locationsProvider =
|
||
NotifierProvider<LocationsNotifier, List<PlantLocation>>(
|
||
LocationsNotifier.new);
|
||
|
||
final locationByIdProvider =
|
||
Provider.family<PlantLocation?, String?>((ref, id) {
|
||
if (id == null) return null;
|
||
final locations = ref.watch(locationsProvider);
|
||
for (final location in locations) {
|
||
if (location.id == id) return location;
|
||
}
|
||
return null;
|
||
});
|