Skip to content

Commit

Permalink
Update to more null-safe hr model
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsRefsgaard committed Jun 27, 2023
1 parent 8ad9f5e commit a6e187d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
library carp_study_app;

import 'dart:async';
import 'dart:isolate';
import 'dart:math';
import 'dart:convert';
import 'dart:ui' as ui;
Expand Down
18 changes: 12 additions & 6 deletions lib/view_models/cards/heart_rate_data_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,18 @@ class HourlyHeartRate extends DataModel {

currentHeartRate = heartRate;
if (hourlyHeartRate.containsKey(hour)) {
hourlyHeartRate.update(
hour,
(value) => value
..min = value.min != null ? min(value.min!, heartRate) : heartRate
..max = value.max != null ? max(value.max!, heartRate) : heartRate,
);
hourlyHeartRate.update(hour, (value) {
double? minVal = value.min, maxVal = value.max;
if (minVal != null && maxVal != null) {
return value
..min = min(minVal, heartRate)
..max = max(maxVal, heartRate);
} else {
return value
..min = heartRate
..max = heartRate;
}
});
} else {
hourlyHeartRate[hour] = HeartRateMinMaxPrHour(heartRate, heartRate);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: 'none'
version: 1.1.0

environment:
sdk: ">=2.17.0 <4.0.0"
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.0.0"

dependencies:
Expand Down

0 comments on commit a6e187d

Please sign in to comment.