Commit aac8db3
Changed files (2)
health_data_store
lib
src
types
test
src
types
health_data_store/lib/src/types/full_entry.dart
@@ -4,6 +4,29 @@ import 'package:health_data_store/health_data_store.dart';
/// time.
typedef FullEntry = (BloodPressureRecord, Note, List<MedicineIntake>);
+extension FastFullEntryGetters on FullEntry {
+ /// Timestamp when the entry occurred.
+ DateTime get time => this.$1.time;
+
+ /// Systolic value of the measurement.
+ Pressure? get sys => this.$1.sys;
+
+ /// Diastolic value of the measurement.
+ Pressure? get dia => this.$1.dia;
+
+ /// Pulse value of the measurement in bpm.
+ int? get pul => this.$1.pul;
+
+ /// Content of the note.
+ String? get note => this.$2.note;
+
+ /// ARGB color in number format.
+ ///
+ /// Can also be obtained through the `dart:ui` Colors `value` attribute.
+ /// Sample value: `0xFF42A5F5`
+ int? get color => this.$2.color;
+}
+
/// Utility methods to work on full entries.
extension FullEntryListUtils on List<FullEntry> {
/// Create a list that only contains the records field from the entries.
health_data_store/test/src/types/full_entry_test.dart
@@ -79,4 +79,24 @@ void main() {
expect(list.distinctMedicines, containsAll([med1, med2, med3]));
});
+ test('fast getters provide correct values', () {
+ final record = mockRecord(
+ sys: 123,
+ dia: 45,
+ pul: 67,
+ );
+ final note = mockNote(
+ note: 'Some test',
+ color: 0xFFEEDD,
+ );
+
+ final FullEntry entry = (record, note, []);
+
+ expect(entry.time, record.time);
+ expect(entry.sys, record.sys);
+ expect(entry.dia, record.dia);
+ expect(entry.pul, record.pul);
+ expect(entry.note, note.note);
+ expect(entry.color, note.color);
+ });
}