Remove BodyWeightState

This wasn't used at the moment, and if we need any filter Methods, we
can add it back
This commit is contained in:
Roland Geider
2026-04-24 12:38:50 +02:00
parent b6923d1a6c
commit 88e0248480

View File

@@ -1,38 +0,0 @@
import 'package:logging/logging.dart';
import 'package:state_notifier/state_notifier.dart';
import 'package:wger/models/body_weight/weight_entry.dart';
/*
* TODO: decide if we want to use the state or just handle a list of entries
*/
class BodyWeightState extends StateNotifier<List<WeightEntry>> {
final _logger = Logger('BodyWeightState');
BodyWeightState([super.initial = const []]);
List<WeightEntry> get items => [...state];
WeightEntry? getNewestEntry() => state.isNotEmpty ? state.first : null;
WeightEntry? findById(String id) {
try {
return state.firstWhere((e) => e.id == id);
} on StateError {
return null;
}
}
WeightEntry? findByDate(DateTime date) {
try {
return state.firstWhere((e) => e.date == date);
} on StateError {
return null;
}
}
void clear() => state = [];
void setItems(List<WeightEntry> entries) {
state = List<WeightEntry>.from(entries);
}
}