Commit f5860b85 authored by Administrator's avatar Administrator

fix more linter warnings

parent 1ad66f50
......@@ -118,7 +118,7 @@ class _AddHeartRateZoneSchemaScreenState
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute<dynamic>(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) =>
AddHeartRateZoneScreen(
heartRateZone: heartRateZone,
......@@ -142,7 +142,7 @@ class _AddHeartRateZoneSchemaScreenState
onPressed: () async {
await Navigator.push(
context,
MaterialPageRoute<dynamic>(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => AddHeartRateZoneScreen(
heartRateZone: HeartRateZone(
heartRateZoneSchema: widget.heartRateZoneSchema),
......
......@@ -114,7 +114,7 @@ class _AddPowerZoneSchemaScreenState extends State<AddPowerZoneSchemaScreen> {
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute<dynamic>(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => AddPowerZoneScreen(
powerZone: powerZone,
base: widget.powerZoneSchema.db.base,
......@@ -137,7 +137,7 @@ class _AddPowerZoneSchemaScreenState extends State<AddPowerZoneSchemaScreen> {
onPressed: () async {
await Navigator.push(
context,
MaterialPageRoute<dynamic>(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => AddPowerZoneScreen(
powerZone:
PowerZone(powerZoneSchema: widget.powerZoneSchema),
......
......@@ -123,7 +123,7 @@ class _AddTagGroupScreenState extends State<AddTagGroupScreen> {
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute<dynamic>(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => AddTagScreen(
tag: tag,
),
......@@ -145,7 +145,7 @@ class _AddTagGroupScreenState extends State<AddTagGroupScreen> {
onPressed: () async {
await Navigator.push(
context,
MaterialPageRoute<dynamic>(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => AddTagScreen(
tag: Tag(tagGroup: widget.tagGroup),
),
......
......@@ -44,7 +44,7 @@ class _DashboardState extends State<Dashboard> {
await athlete.readCredentials();
await Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => ShowAthleteScreen(athlete: athlete),
),
);
......@@ -55,7 +55,7 @@ class _DashboardState extends State<Dashboard> {
await athlete.readCredentials();
await Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => EditAthleteScreen(athlete: athlete),
),
);
......@@ -86,7 +86,7 @@ class _DashboardState extends State<Dashboard> {
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => IntroductionScreen(),
),
);
......
......@@ -21,7 +21,7 @@ class EditAthleteScreen extends StatelessWidget {
backgroundColor: MyColor.athlete,
title: const Text('Create Athlete'),
),
body: ChangeNotifierProvider.value(
body: ChangeNotifierProvider<Athlete>.value(
value: athlete,
child: Consumer<Athlete>(
builder: (BuildContext context, Athlete athlete, Widget _child) =>
......@@ -56,7 +56,7 @@ class EditAthleteScreen extends StatelessWidget {
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) =>
StravaGetUser(athlete: athlete),
),
......@@ -104,7 +104,7 @@ class EditAthleteScreen extends StatelessWidget {
TextFormField(
decoration: const InputDecoration(labelText: 'First name'),
initialValue: athlete.db.firstName,
onChanged: (value) => athlete.firstName = value,
onChanged: (String value) => athlete.firstName = value,
),
TextFormField(
decoration: const InputDecoration(labelText: 'Last name'),
......@@ -190,13 +190,13 @@ class EditAthleteScreen extends StatelessWidget {
}
}
saveStravaUser(BuildContext context) async {
Future<void> saveStravaUser(BuildContext context) async {
await athlete.db.save();
await athlete.storeCredentials();
Navigator.of(context).pop();
}
saveStandaloneUser(BuildContext context) async {
Future<void> saveStandaloneUser(BuildContext context) async {
athlete.db.firstName = athlete.firstName ?? athlete.db.firstName;
athlete.db.lastName = athlete.lastName ?? athlete.db.lastName;
await athlete.save();
......
......@@ -3,11 +3,6 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
class ShowActivityDetailScreen extends StatelessWidget {
final Activity activity;
final Widget widget;
final String title;
final Color backgroundColor;
const ShowActivityDetailScreen({
Key key,
this.activity,
......@@ -16,6 +11,11 @@ class ShowActivityDetailScreen extends StatelessWidget {
this.backgroundColor,
}) : super(key: key);
final Activity activity;
final Widget widget;
final String title;
final Color backgroundColor;
@override
Widget build(BuildContext context) {
return Scaffold(
......
......@@ -258,7 +258,7 @@ class _ShowActivityScreenState extends State<ShowActivityScreen> {
label: Text(title),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => ShowActivityDetailScreen(
activity: widget.activity,
widget: nextWidget,
......
......@@ -3,11 +3,6 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/athlete.dart';
class ShowAthleteDetailScreen extends StatelessWidget {
final Athlete athlete;
final Widget widget;
final String title;
final Color backgroundColor;
const ShowAthleteDetailScreen({
Key key,
this.athlete,
......@@ -16,6 +11,11 @@ class ShowAthleteDetailScreen extends StatelessWidget {
this.backgroundColor,
}) : super(key: key);
final Athlete athlete;
final Widget widget;
final String title;
final Color backgroundColor;
@override
Widget build(BuildContext context) {
return Scaffold(
......
......@@ -201,7 +201,7 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
label: Text(title),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => ShowAthleteDetailScreen(
athlete: widget.athlete,
widget: nextWidget,
......
......@@ -4,11 +4,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class ShowLapDetailScreen extends StatefulWidget {
final Lap lap;
final List<Lap> laps;
final Function({Lap lap}) nextWidget;
final String title;
const ShowLapDetailScreen({
Key key,
@required this.lap,
......@@ -17,6 +12,11 @@ class ShowLapDetailScreen extends StatefulWidget {
@required this.title,
}) : super(key: key);
final Lap lap;
final List<Lap> laps;
final Widget Function({Lap lap}) nextWidget;
final String title;
@override
_ShowLapDetailScreenState createState() => _ShowLapDetailScreenState();
}
......@@ -43,10 +43,10 @@ class _ShowLapDetailScreenState extends State<ShowLapDetailScreen> {
),
body: GestureDetector(
child: widget.nextWidget(lap: currentLap),
onHorizontalDragUpdate: (details) {
onHorizontalDragUpdate: (DragUpdateDetails details) {
dragAmount = dragAmount + details.primaryDelta;
},
onHorizontalDragEnd: (details) {
onHorizontalDragEnd: (DragEndDetails details) {
if (dragAmount < -50) {
dragAmount = 0;
if (currentLap.index < widget.laps.length) {
......
......@@ -41,7 +41,7 @@ class ShowLapScreen extends StatelessWidget {
),
),
body: StaggeredGridView.count(
staggeredTiles: List.filled(12, const StaggeredTile.fit(1)),
staggeredTiles: List<StaggeredTile>.filled(12, const StaggeredTile.fit(1)),
crossAxisSpacing: 10,
padding: const EdgeInsets.all(10),
crossAxisCount:
......@@ -144,7 +144,7 @@ class ShowLapScreen extends StatelessWidget {
Widget navigationButton({
@required BuildContext context,
@required Function({Lap lap}) nextWidget,
@required Widget Function({Lap lap}) nextWidget,
@required Widget icon,
@required String title,
@required Color color,
......@@ -156,7 +156,7 @@ class ShowLapScreen extends StatelessWidget {
label: Text(title),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => ShowLapDetailScreen(
lap: lap,
laps: laps,
......
......@@ -14,7 +14,7 @@ class StravaGetUser extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider.value(
return ChangeNotifierProvider<Athlete>.value(
value: athlete,
child: Scaffold(
appBar: AppBar(
......
......@@ -138,7 +138,7 @@ class _AthleteTimeSeriesChartState extends State<AthleteTimeSeriesChart> {
child: Text(selectedActivity.db.name),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => ShowActivityScreen(
activity: selectedActivity,
athlete: widget.athlete,
......
......@@ -10,35 +10,35 @@ class MyButton extends RaisedButton {
: super(
color: MyColor.delete,
textColor: Colors.white,
child: child ?? Text('Delete'),
child: child ?? const Text('Delete'),
onPressed: onPressed,
);
MyButton.cancel({Widget child, VoidCallback onPressed})
: super(
color: MyColor.cancel,
child: child ?? Text('Cancel'),
child: child ?? const Text('Cancel'),
onPressed: onPressed,
);
MyButton.save({Widget child, VoidCallback onPressed})
: super(
color: MyColor.save,
child: child ?? Text('Save'),
child: child ?? const Text('Save'),
onPressed: onPressed,
);
MyButton.add({Widget child, VoidCallback onPressed})
: super(
color: MyColor.add,
child: child ?? Text('Add'),
child: child ?? const Text('Add'),
onPressed: onPressed,
);
MyButton.navigate({Widget child, VoidCallback onPressed})
: super(
color: MyColor.navigate,
child: child ?? Text('Navigate'),
child: child ?? const Text('Navigate'),
onPressed: onPressed,
);
......@@ -46,7 +46,7 @@ class MyButton extends RaisedButton {
: super(
color: MyColor.detail,
textColor: Colors.white,
child: child ?? Text('Detail'),
child: child ?? const Text('Detail'),
onPressed: onPressed,
);
......@@ -54,7 +54,7 @@ class MyButton extends RaisedButton {
: super(
color: MyColor.activity,
textColor: Colors.white,
child: child ?? Text('Activity'),
child: child ?? const Text('Activity'),
onPressed: onPressed,
);
}
......@@ -66,7 +66,7 @@ class MyColor {
static Color textColor({
@required Color backgroundColor,
bool selected:true,
bool selected = true,
}) {
if (selected) {
if (ThemeData.estimateBrightnessForColor(backgroundColor) ==
......
......@@ -4,15 +4,15 @@ import 'package:flutter/material.dart';
class MyTheme{
static ThemeData call() {
var redness = MyColor.primary.red;
var greenness = MyColor.primary.green;
var blueness = MyColor.primary.blue;
final int redness = MyColor.primary.red;
final int greenness = MyColor.primary.green;
final int blueness = MyColor.primary.blue;
return ThemeData(
brightness: Brightness.light,
primaryColor: MyColor.primary,
primarySwatch: MaterialColor(
MyColor.sunFlowerAccent.value,
{
<int, Color>{
50: Color.fromRGBO(redness, greenness, blueness, .1),
100: Color.fromRGBO(redness, greenness, blueness, .2),
200: Color.fromRGBO(redness, greenness, blueness, .3),
......
......@@ -56,7 +56,7 @@ class _ActivitiesListWidgetState extends State<ActivitiesListWidget> {
activity.averagePowerString()),
],
),
trailing: ChangeNotifierProvider.value(
trailing: ChangeNotifierProvider<Activity>.value(
value: activity,
child: Consumer<Activity>(
builder: (BuildContext context, Activity activity, Widget _child) =>
......@@ -67,7 +67,7 @@ class _ActivitiesListWidgetState extends State<ActivitiesListWidget> {
if (activity.db.state == 'persisted')
Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => ShowActivityScreen(
activity: activity,
athlete: widget.athlete,
......
import 'package:encrateia/models/heart_rate_zone.dart';
import 'package:encrateia/models/heart_rate_zone_schema.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/power_zone.dart';
......@@ -6,14 +7,14 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
class ActivityBarGraphWidget extends StatefulWidget {
final Activity activity;
final Athlete athlete;
ActivityBarGraphWidget({
const ActivityBarGraphWidget({
@required this.activity,
@required this.athlete,
});
final Activity activity;
final Athlete athlete;
@override
_ActivityBarGraphWidgetState createState() => _ActivityBarGraphWidgetState();
}
......@@ -21,8 +22,8 @@ class ActivityBarGraphWidget extends StatefulWidget {
class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
PowerZoneSchema _powerZoneSchema;
HeartRateZoneSchema _heartRateZoneSchema;
List<PowerZone> _powerZones = [];
List<HeartRateZoneSchema> _heartRateZones = [];
List<PowerZone> _powerZones = <PowerZone>[];
List<HeartRateZone> _heartRateZones = <HeartRateZone>[];
@override
void initState() {
......@@ -31,12 +32,12 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
}
@override
Widget build(context) {
return Text("hi!");
Widget build(BuildContext context) {
return const Text('hi!');
}
getData() async {
Activity activity = widget.activity;
Future<void> getData() async {
final Activity activity = widget.activity;
_powerZoneSchema = await activity.powerZoneSchema;
if (_powerZoneSchema != null)
......@@ -45,7 +46,7 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
_heartRateZoneSchema = await activity.heartRateZoneSchema;
if (_heartRateZoneSchema != null)
_heartRateZoneSchema = await _heartRateZoneSchema.heartRateZones;
_heartRateZones = await _heartRateZoneSchema.heartRateZones;
print(_heartRateZones.length);
setState(() {});
......
......@@ -8,14 +8,14 @@ import 'package:encrateia/utils/num_utils.dart';
import 'package:encrateia/utils/icon_utils.dart';
class ActivitySpeedPerHeartRateWidget extends StatefulWidget {
final Activity activity;
final Athlete athlete;
ActivitySpeedPerHeartRateWidget({
const ActivitySpeedPerHeartRateWidget({
@required this.activity,
@required this.athlete,
});
final Activity activity;
final Athlete athlete;
@override
_ActivitySpeedPerHeartRateWidgetState createState() =>
_ActivitySpeedPerHeartRateWidgetState();
......@@ -23,8 +23,8 @@ class ActivitySpeedPerHeartRateWidget extends StatefulWidget {
class _ActivitySpeedPerHeartRateWidgetState
extends State<ActivitySpeedPerHeartRateWidget> {
var records = RecordList(<Event>[]);
String avgSpeedPerHeartRateString = "Loading ...";
RecordList<Event> records = RecordList<Event>(<Event>[]);
String avgSpeedPerHeartRateString = 'Loading ...';
@override
void initState() {
......@@ -33,56 +33,56 @@ class _ActivitySpeedPerHeartRateWidgetState
}
@override
Widget build(context) {
if (records.length > 0) {
var speedPerHeartRateRecords = records
.where((value) =>
Widget build(BuildContext context) {
if (records.isNotEmpty) {
final List<Event> speedPerHeartRateRecords = records
.where((Event value) =>
value.db.speed != null &&
value.db.heartRate != null &&
value.db.heartRate > 0)
.toList();
if (speedPerHeartRateRecords.length > 0) {
if (speedPerHeartRateRecords.isNotEmpty) {
return ListTileTheme(
iconColor: Colors.deepOrange,
child: ListView(
padding: EdgeInsets.only(left: 25),
padding: const EdgeInsets.only(left: 25),
children: <Widget>[
ActivitySpeedPerHeartRateChart(
records: RecordList(speedPerHeartRateRecords),
records: RecordList<Event>(speedPerHeartRateRecords),
activity: widget.activity,
athlete: widget.athlete,
),
Text('${widget.athlete.db.recordAggregationCount} records are '
'aggregated into one point in the plot. Only records where '
'speed is present and heart rate > 0 bpm are shown.'),
Divider(),
const Divider(),
ListTile(
leading: MyIcon.average,
title: Text(avgSpeedPerHeartRateString),
subtitle: Text("average speed per heart rate"),
subtitle: const Text('average speed per heart rate'),
),
],
),
);
} else {
return Center(
child: Text("No speed per heart rate data available."),
return const Center(
child: Text('No speed per heart rate data available.'),
);
}
} else {
return Center(
child: Text("Loading"),
return const Center(
child: Text('Loading'),
);
}
}
getData() async {
Activity activity = widget.activity;
records = RecordList(await activity.records);
Future<void> getData() async {
final Activity activity = widget.activity;
records = RecordList<Event>(await activity.records);
double avg = 1000 * activity.db.avgSpeed / activity.db.avgHeartRate;
avgSpeedPerHeartRateString = avg.toStringOrDashes(1) + " m/h / bpm";
final double avg = 1000 * activity.db.avgSpeed / activity.db.avgHeartRate;
avgSpeedPerHeartRateString = avg.toStringOrDashes(1) + ' m/h / bpm';
setState(() {});
}
}
......@@ -59,7 +59,7 @@ class _AthleteBodyWeightWidgetState extends State<AthleteBodyWeightWidget> {
DataCell(MyIcon.edit, onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => AddWeightScreen(weight: weight),
),
);
......@@ -85,7 +85,7 @@ class _AthleteBodyWeightWidgetState extends State<AthleteBodyWeightWidget> {
onPressed: () async {
await Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => AddWeightScreen(
weight: Weight(athlete: widget.athlete),
),
......@@ -151,7 +151,7 @@ Or you can simply enter your current weight using the New Weighting button.
onPressed: () async {
await Navigator.push(
context,
MaterialPageRoute(
MaterialPageRoute<BuildContext>(
builder: (BuildContext context) => AddWeightScreen(
weight: Weight(athlete: widget.athlete),
),
......
......@@ -6,16 +6,16 @@ import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/activity.dart';
class AthleteEcorWidget extends StatefulWidget {
final Athlete athlete;
AthleteEcorWidget({this.athlete});
const AthleteEcorWidget({this.athlete});
final Athlete athlete;
@override
_AthleteEcorWidgetState createState() => _AthleteEcorWidgetState();
}
class _AthleteEcorWidgetState extends State<AthleteEcorWidget> {
List<Activity> activities = [];
List<Activity> activities = <Activity>[];
@override
void initState() {
......@@ -24,31 +24,31 @@ class _AthleteEcorWidgetState extends State<AthleteEcorWidget> {
}
@override
Widget build(context) {
if (activities.length == 0) {
return Center(
child: Text("Loading"),
Widget build(BuildContext context) {
if (activities.isEmpty) {
return const Center(
child: Text('Loading'),
);
} else {
var ecorActivities = activities
.where((activity) =>
final List<Activity> ecorActivities = activities
.where((Activity activity) =>
activity.db.avgPower != null &&
activity.db.avgPower > 0 &&
activity.db.avgSpeed != null)
.toList();
if (ecorActivities.length == 0) {
return Center(
child: Text("No ecor data available."),
if (ecorActivities.isEmpty) {
return const Center(
child: Text('No ecor data available.'),
);
} else if (ecorActivities.first.weight == null) {