wip: null safety
parent
33591e33ad
commit
cd2d09d823
File diff suppressed because one or more lines are too long
|
@ -38,6 +38,9 @@ Future<void> catchUp({required List<Activity> backlog}) async {
|
|||
double calculate({required List<Event> records}) {
|
||||
final PowerDuration powerDuration = PowerDuration(records: records);
|
||||
final PowerDuration ftpCurve = powerDuration.normalize();
|
||||
final double ftp = ftpCurve.powerMap.values.toList().reduce(max);
|
||||
return ftp;
|
||||
final List<double> powerValues = ftpCurve.powerMap.values.toList();
|
||||
if (powerValues.isNotEmpty) {
|
||||
return ftpCurve.powerMap.values.toList().reduce(max);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -232,9 +232,9 @@ class Lap {
|
|||
return lap;
|
||||
}
|
||||
|
||||
Future<List<Event>?> get records async {
|
||||
Future<List<Event>> get records async {
|
||||
_records ??= await Event.recordsByLap(this);
|
||||
return _records;
|
||||
return _records ?? <Event>[];
|
||||
}
|
||||
|
||||
Future<PowerZoneSchema?> get powerZoneSchema async {
|
||||
|
@ -265,7 +265,7 @@ class Lap {
|
|||
|
||||
Future<void> setAverages() async {
|
||||
final RecordList<Event> recordList =
|
||||
RecordList<Event>(await (records as Future<List<Event>>));
|
||||
RecordList<Event>(await records);
|
||||
final RecordList<Event> eventList = RecordList<Event>(await events);
|
||||
_db
|
||||
..avgPower = recordList.avgPower()
|
||||
|
@ -374,7 +374,7 @@ class Lap {
|
|||
Future<List<BarZone>> powerZoneCounts() async {
|
||||
final PowerZoneSchema powerZoneSchema =
|
||||
await (this.powerZoneSchema as Future<PowerZoneSchema>);
|
||||
final List<Event> records = await (this.records as Future<List<Event>>);
|
||||
final List<Event> records = await this.records;
|
||||
final List<Event> powerRecords =
|
||||
records.where((Event record) => record.power != null).toList();
|
||||
final List<BarZone> powerZoneCounts = await RecordList<Event>(powerRecords)
|
||||
|
@ -385,7 +385,7 @@ class Lap {
|
|||
Future<List<BarZone>> heartRateZoneCounts() async {
|
||||
final HeartRateZoneSchema heartRateZoneSchema =
|
||||
await (this.heartRateZoneSchema as Future<HeartRateZoneSchema>);
|
||||
final List<Event> records = await (this.records as Future<List<Event>>);
|
||||
final List<Event> records = await this.records;
|
||||
final List<Event> heartRateRecords =
|
||||
records.where((Event record) => record.heartRate != null).toList();
|
||||
final List<BarZone> heartRateZoneCounts =
|
||||
|
|
|
@ -26,9 +26,9 @@ extension StatisticFunctions on Iterable<dynamic> {
|
|||
return values.reduce(math.max);
|
||||
}
|
||||
|
||||
List<num> nonZeros() {
|
||||
final List<num> values = toList().cast<num>();
|
||||
final Iterable<num> nonZeroValues = values.where((num value) => value != 0);
|
||||
return nonZeroValues.toList();
|
||||
List<num?> nonZeros() {
|
||||
final List<num> values = whereType<num>().toList();
|
||||
final Iterable<num?> nonZeroValues = values.where((num value) => value != 0);
|
||||
return nonZeroValues.isNotEmpty ? nonZeroValues.toList() : <num>[];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ class _LapAltitudeWidgetState extends State<LapAltitudeWidget> {
|
|||
|
||||
Future<void> getData() async {
|
||||
final Lap lap = widget.lap!;
|
||||
records = RecordList<Event>(await (lap.records as Future<List<Event>>));
|
||||
records = RecordList<Event> (await lap.records);
|
||||
|
||||
setState(() => loading = false);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ class _LapEcorWidgetState extends State<LapEcorWidget> {
|
|||
}
|
||||
|
||||
Future<void> getData() async {
|
||||
records = RecordList<Event>(await (widget.lap!.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await widget.lap!.records);
|
||||
weight = await Weight.getBy(
|
||||
athletesId: widget.athlete!.id,
|
||||
date: widget.lap!.startTime,
|
||||
|
|
|
@ -105,7 +105,7 @@ class _LapFormPowerWidgetState extends State<LapFormPowerWidget> {
|
|||
|
||||
Future<void> getData() async {
|
||||
final Lap lap = widget.lap!;
|
||||
records = RecordList<Event>(await (lap.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await lap.records);
|
||||
setState(() => loading = false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class _LapGroundTimeWidgetState extends State<LapGroundTimeWidget> {
|
|||
|
||||
Future<void> getData() async {
|
||||
final Lap lap = widget.lap!;
|
||||
records = RecordList<Event>(await (lap.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await lap.records);
|
||||
setState(() => loading = false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ class _LapHeartRateWidgetState extends State<LapHeartRateWidget> {
|
|||
}
|
||||
|
||||
Future<void> getData() async {
|
||||
records = RecordList<Event>(await (widget.lap!.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await widget.lap!.records);
|
||||
heartRateZoneSchema = await widget.lap!.heartRateZoneSchema;
|
||||
if (heartRateZoneSchema != null) {
|
||||
heartRateZones = await heartRateZoneSchema!.heartRateZones;
|
||||
|
|
|
@ -115,7 +115,7 @@ class _LapLegSpringStiffnessWidgetState
|
|||
}
|
||||
|
||||
Future<void> getData() async {
|
||||
records = RecordList<Event>(await (widget.lap!.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await widget.lap!.records);
|
||||
setState(() => loading = false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ class _LapPaceWidgetState extends State<LapPaceWidget> {
|
|||
|
||||
Future<void> getData() async {
|
||||
final Lap lap = widget.lap!;
|
||||
records = RecordList<Event>(await (lap.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await lap.records);
|
||||
setState(() => loading = false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class _LapPowerDurationWidgetState extends State<LapPowerDurationWidget> {
|
|||
}
|
||||
|
||||
Future<void> getData() async {
|
||||
records = RecordList<Event>(await (widget.lap!.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await widget.lap!.records);
|
||||
setState(() => loading = false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ class _LapPowerWidgetState extends State<LapPowerWidget> {
|
|||
}
|
||||
|
||||
Future<void> getData() async {
|
||||
records = RecordList<Event>(await (widget.lap!.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await widget.lap!.records);
|
||||
powerZoneSchema = await widget.lap!.powerZoneSchema;
|
||||
if (powerZoneSchema != null) {
|
||||
powerZones = await powerZoneSchema!.powerZones;
|
||||
|
|
|
@ -114,7 +114,7 @@ class _LapSpeedWidgetState extends State<LapSpeedWidget> {
|
|||
}
|
||||
|
||||
Future<void> getData() async {
|
||||
records = RecordList<Event>(await (widget.lap!.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await widget.lap!.records);
|
||||
setState(() => loading = false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class _LapStrydCadenceWidgetState extends State<LapStrydCadenceWidget> {
|
|||
}
|
||||
|
||||
Future<void> getData() async {
|
||||
records = RecordList<Event>(await (widget.lap!.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await widget.lap!.records);
|
||||
setState(() => loading = false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ class _LapVerticalOscillationWidgetState
|
|||
}
|
||||
|
||||
Future<void> getData() async {
|
||||
records = RecordList<Event>(await (widget.lap!.records as Future<List<Event>>));
|
||||
records = RecordList<Event>(await widget.lap!.records);
|
||||
setState(() => loading = false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ class _LapsListWidgetState extends State<LapsListWidget> {
|
|||
}
|
||||
|
||||
Future<void> copyToInterval({required Lap lap}) async {
|
||||
final List<Event> records = await (lap.records as Future<List<Event>>);
|
||||
final List<Event> records = await lap.records;
|
||||
|
||||
final encrateia.Interval interval = encrateia.Interval()
|
||||
..athletesId = widget.athlete!.id
|
||||
|
|
Reference in New Issue