wip: null safety

upgrade-2021-project
Stefan Haslinger 2022-03-11 13:21:13 +01:00
parent 35ad49e345
commit 073e77cc98
19 changed files with 53 additions and 55 deletions

File diff suppressed because one or more lines are too long

View File

@ -24,8 +24,8 @@ class ActivityList<E> extends DelegatingList<E> {
for (int olderIndex = index + 1;
olderIndex < _activities.length;
olderIndex++) {
final double daysAgo = activity.timeCreated!
.difference(_activities[olderIndex].timeCreated!)
final double daysAgo = activity.timeCreated
.difference(_activities[olderIndex].timeCreated)
.inHours /
24;
if (daysAgo > fullDecay) {

View File

@ -240,7 +240,7 @@ class Lap {
Future<PowerZoneSchema?> get powerZoneSchema async {
if (_powerZoneSchema == null) {
final DbActivity dbActivity =
await (DbActivity().getById(activitiesId) as Future<DbActivity>);
(await DbActivity().getById(activitiesId))!;
_powerZoneSchema = await PowerZoneSchema.getBy(
athletesId: dbActivity.athletesId,
@ -252,8 +252,7 @@ class Lap {
Future<HeartRateZoneSchema?> get heartRateZoneSchema async {
if (_heartRateZoneSchema == null) {
final DbActivity dbActivity =
await (DbActivity().getById(activitiesId) as Future<DbActivity>);
final DbActivity dbActivity = (await DbActivity().getById(activitiesId))!;
_heartRateZoneSchema = await HeartRateZoneSchema.getBy(
athletesId: dbActivity.athletesId,
@ -264,8 +263,7 @@ class Lap {
}
Future<void> setAverages() async {
final RecordList<Event> recordList =
RecordList<Event>(await records);
final RecordList<Event> recordList = RecordList<Event>(await records);
final RecordList<Event> eventList = RecordList<Event>(await events);
_db
..avgPower = recordList.avgPower()

View File

@ -88,7 +88,7 @@ class _AthleteTimeSeriesChartState extends State<AthleteTimeSeriesChart> {
? 1
: 2,
child: TimeSeriesChart(
data as List<Series<dynamic, DateTime>>,
data,
animate: true,
flipVerticalAxis: widget.flipVerticalAxis ?? false,
selectionModels: <SelectionModelConfig<DateTime>>[

View File

@ -28,9 +28,9 @@ class ActivityAltitudeChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<DoublePlotPoint, int?>> data =
<Series<DoublePlotPoint, int?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, int>> data =
<Series<DoublePlotPoint, int>>[
Series<DoublePlotPoint, int>(
id: 'Altitude',
colorFn: (_, __) => Color.black,
domainFn: (DoublePlotPoint record, _) => record.domain,

View File

@ -31,9 +31,9 @@ class ActivityEcorChart extends StatelessWidget {
weight: weight,
);
final List<Series<DoublePlotPoint, int?>> data =
<Series<DoublePlotPoint, int?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, int>> data =
<Series<DoublePlotPoint, int>>[
Series<DoublePlotPoint, int>(
id: 'Ecor',
colorFn: (_, __) => Color.black,
domainFn: (DoublePlotPoint record, _) => record.domain,

View File

@ -32,8 +32,8 @@ class ActivityFormPowerChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<IntPlotPoint, int?>> data = <Series<IntPlotPoint, int?>>[
Series<IntPlotPoint, int?>(
final List<Series<IntPlotPoint, int>> data = <Series<IntPlotPoint, int>>[
Series<IntPlotPoint, int>(
id: 'Form power',
colorFn: (_, __) => Color.black,
domainFn: (IntPlotPoint record, _) => record.domain,

View File

@ -32,9 +32,9 @@ class ActivityGroundTimeChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<DoublePlotPoint, int?>> data =
<Series<DoublePlotPoint, int?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, int>> data =
<Series<DoublePlotPoint, int>>[
Series<DoublePlotPoint, int>(
id: 'Ground Time',
colorFn: (_, __) => Color.black,
domainFn: (DoublePlotPoint record, _) => record.domain,

View File

@ -28,9 +28,9 @@ class ActivityLegSpringStiffnessChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<DoublePlotPoint, int?>> data =
<Series<DoublePlotPoint, int?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, int>> data =
<Series<DoublePlotPoint, int>>[
Series<DoublePlotPoint, int>(
id: 'Leg spring stiffness',
colorFn: (_, __) => Color.black,
domainFn: (DoublePlotPoint record, _) => record.domain,

View File

@ -32,9 +32,9 @@ class ActivityPaceChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<DoublePlotPoint, int?>> data =
<Series<DoublePlotPoint, int?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, int>> data =
<Series<DoublePlotPoint, int>>[
Series<DoublePlotPoint, int>(
id: 'Pace',
colorFn: (_, __) => Color.black,
domainFn: (DoublePlotPoint record, _) => record.domain,

View File

@ -31,8 +31,8 @@ class ActivityPowerChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<IntPlotPoint, int?>> data = <Series<IntPlotPoint, int?>>[
Series<IntPlotPoint, int?>(
final List<Series<IntPlotPoint, int>> data = <Series<IntPlotPoint, int>>[
Series<IntPlotPoint, int>(
id: 'Power',
colorFn: (_, __) => Color.black,
domainFn: (IntPlotPoint record, _) => record.domain,

View File

@ -28,9 +28,9 @@ class ActivityPowerPerHeartRateChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<DoublePlotPoint, int?>> data =
<Series<DoublePlotPoint, int?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, int>> data =
<Series<DoublePlotPoint, int>>[
Series<DoublePlotPoint, int>(
id: 'Power per Heart Rate',
colorFn: (_, __) => Color.black,
domainFn: (DoublePlotPoint record, _) => record.domain,

View File

@ -28,9 +28,9 @@ class ActivityPowerRatioChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<DoublePlotPoint, int?>> data =
<Series<DoublePlotPoint, int?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, int>> data =
<Series<DoublePlotPoint, int>>[
Series<DoublePlotPoint, int>(
id: 'Power Ratio',
colorFn: (_, __) => Color.black,
domainFn: (DoublePlotPoint record, _) => record.domain,

View File

@ -32,9 +32,9 @@ class ActivitySpeedChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<DoublePlotPoint, int?>> data =
<Series<DoublePlotPoint, int?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, int>> data =
<Series<DoublePlotPoint, int>>[
Series<DoublePlotPoint, int>(
id: 'Speed',
colorFn: (_, __) => Color.black,
domainFn: (DoublePlotPoint record, _) => record.domain,

View File

@ -28,9 +28,9 @@ class ActivitySpeedPerHeartRateChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<DoublePlotPoint, int?>> data =
<Series<DoublePlotPoint, int?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, int>> data =
<Series<DoublePlotPoint, int>>[
Series<DoublePlotPoint, int>(
id: 'Speed per Heart Rate',
colorFn: (_, __) => Color.black,
domainFn: (DoublePlotPoint record, _) => record.domain,

View File

@ -32,9 +32,9 @@ class ActivityStrydCadenceChart extends StatelessWidget {
amount: athlete!.recordAggregationCount,
);
final List<Series<DoublePlotPoint, int?>> data =
<Series<DoublePlotPoint, int?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, int>> data =
<Series<DoublePlotPoint, int>>[
Series<DoublePlotPoint, int>(
id: 'Cadence',
colorFn: (_, __) => Color.black,
domainFn: (DoublePlotPoint record, _) => record.domain,

View File

@ -14,9 +14,9 @@ class FtpChart extends StatelessWidget {
final PowerDuration powerDuration = PowerDuration(records: records!);
final PowerDuration ftpCurve = powerDuration.normalize();
final List<Series<DoublePlotPoint, num?>> data =
<Series<DoublePlotPoint, num?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, num>> data =
<Series<DoublePlotPoint, num>>[
Series<DoublePlotPoint, int>(
id: 'Power Duration',
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
domainFn: (DoublePlotPoint record, _) => record.domain,
@ -59,7 +59,7 @@ class FtpChart extends StatelessWidget {
aspectRatio:
MediaQuery.of(context).orientation == Orientation.portrait ? 1 : 2,
child: LineChart(
data as List<Series<dynamic, num>>,
data,
defaultRenderer: LineRendererConfig<num>(
includeArea: true,
strokeWidthPx: 1,

View File

@ -13,9 +13,9 @@ class PowerDurationChart extends StatelessWidget {
Widget build(BuildContext context) {
final PowerDuration powerDuration = PowerDuration(records: records!);
final List<Series<DoublePlotPoint, num?>> data =
<Series<DoublePlotPoint, num?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, num>> data =
<Series<DoublePlotPoint, num>>[
Series<DoublePlotPoint, int>(
id: 'Power Duration',
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
domainFn: (DoublePlotPoint record, _) => record.domain,
@ -58,7 +58,7 @@ class PowerDurationChart extends StatelessWidget {
aspectRatio:
MediaQuery.of(context).orientation == Orientation.portrait ? 1 : 2,
child: LineChart(
data as List<Series<dynamic, num>>,
data,
defaultRenderer: LineRendererConfig<num>(
includeArea: true,
strokeWidthPx: 1,

View File

@ -15,9 +15,9 @@ class WorkChart extends StatelessWidget {
final CriticalPower criticalPower = CriticalPower(records: records!);
final CriticalPower workCurve = criticalPower.workify();
final List<Series<DoublePlotPoint, num?>> data =
<Series<DoublePlotPoint, num?>>[
Series<DoublePlotPoint, int?>(
final List<Series<DoublePlotPoint, num>> data =
<Series<DoublePlotPoint, num>>[
Series<DoublePlotPoint, int>(
id: 'Work',
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
domainFn: (DoublePlotPoint record, _) => record.domain,
@ -62,7 +62,7 @@ class WorkChart extends StatelessWidget {
? 1
: 2,
child: LineChart(
data as List<Series<dynamic, num>>,
data,
defaultRenderer: LineRendererConfig<num>(
includeArea: true,
strokeWidthPx: 1,