feat:更新历史记录模块

This commit is contained in:
2025-12-02 20:00:34 +08:00
parent 62108248aa
commit b3bb3378c3
6 changed files with 50 additions and 66 deletions

View File

@@ -93,17 +93,18 @@ class HealthService {
Future<bool> updateRecord(HealthRecord record) async {
try {
List<HealthRecord> records =
print(record.date);
final existingRecords =
box.values.where((item) => item.date == record.date).toList();
if (records.isEmpty) {
if (existingRecords.isEmpty) {
await addRecord(record);
} else {
await record.save();
}
return true;
} catch (e) {
print(e.toString());
return false;
}
}