mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-06 15:54:31 +01:00
const_constructors
info: Prefer const with constant constructors. prefer_const_constructors
This commit is contained in:
1 parent
e5a6d930cb
commit
9d479e89b0
58 files changed
+354
-353
No files matched your search
@@ -90,7 +90,7 @@ linter:
|
||||
prefer_asserts_in_initializer_lists: true
|
||||
prefer_collection_literals: true
|
||||
prefer_conditional_assignment: true
|
||||
prefer_const_constructors: false # definitely to be changed
|
||||
prefer_const_constructors: true
|
||||
prefer_const_constructors_in_immutables: true
|
||||
prefer_const_declarations: true
|
||||
prefer_const_literals_to_create_immutables: true
|
||||
|
||||
@@ -60,5 +60,5 @@ String? timeToString(TimeOfDay? time) {
|
||||
if (time == null) {
|
||||
return null;
|
||||
}
|
||||
return DefaultMaterialLocalizations().formatTimeOfDay(time, alwaysUse24HourFormat: true);
|
||||
return const DefaultMaterialLocalizations().formatTimeOfDay(time, alwaysUse24HourFormat: true);
|
||||
}
|
||||
+2
-2
@@ -52,7 +52,7 @@ void showHttpExceptionErrorDialog(WgerHttpException exception, BuildContext cont
|
||||
final List<Widget> errorList = [];
|
||||
for (final key in exception.errors!.keys) {
|
||||
// Error headers
|
||||
errorList.add(Text(key, style: TextStyle(fontWeight: FontWeight.bold)));
|
||||
errorList.add(Text(key, style: const TextStyle(fontWeight: FontWeight.bold)));
|
||||
|
||||
// Error messages
|
||||
if (exception.errors![key] is String) {
|
||||
@@ -62,7 +62,7 @@ void showHttpExceptionErrorDialog(WgerHttpException exception, BuildContext cont
|
||||
errorList.add(Text(value));
|
||||
}
|
||||
}
|
||||
errorList.add(SizedBox(height: 8));
|
||||
errorList.add(const SizedBox(height: 8));
|
||||
}
|
||||
|
||||
showDialog(
|
||||
|
||||
@@ -160,7 +160,7 @@ class ExercisesProvider extends WgerBaseProvider with ChangeNotifier {
|
||||
// Save the result to the cache
|
||||
final exerciseData = {
|
||||
'date': DateTime.now().toIso8601String(),
|
||||
'expiresIn': DateTime.now().add(Duration(days: daysToCache)).toIso8601String(),
|
||||
'expiresIn': DateTime.now().add(const Duration(days: daysToCache)).toIso8601String(),
|
||||
'exercises': _exercises.map((e) => e.toJson()).toList(),
|
||||
'equipment': _equipment.map((e) => e.toJson()).toList(),
|
||||
'categories': _categories.map((e) => e.toJson()).toList(),
|
||||
|
||||
@@ -292,7 +292,7 @@ class NutritionPlansProvider extends WgerBaseProvider with ChangeNotifier {
|
||||
// Initialise an empty cache
|
||||
final ingredientData = {
|
||||
'date': DateTime.now().toIso8601String(),
|
||||
'expiresIn': DateTime.now().add(Duration(days: DAYS_TO_CACHE)).toIso8601String(),
|
||||
'expiresIn': DateTime.now().add(const Duration(days: DAYS_TO_CACHE)).toIso8601String(),
|
||||
'ingredients': []
|
||||
};
|
||||
prefs.setString('ingredientData', json.encode(ingredientData));
|
||||
|
||||
@@ -353,7 +353,7 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier {
|
||||
// Save the result to the cache
|
||||
final exerciseData = {
|
||||
'date': DateTime.now().toIso8601String(),
|
||||
'expiresIn': DateTime.now().add(Duration(days: DAYS_TO_CACHE)).toIso8601String(),
|
||||
'expiresIn': DateTime.now().add(const Duration(days: DAYS_TO_CACHE)).toIso8601String(),
|
||||
'repetitionUnits': _repetitionUnit.map((e) => e.toJson()).toList(),
|
||||
'weightUnit': _weightUnits.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
@@ -49,15 +49,15 @@ class AuthScreen extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 20)),
|
||||
Image(
|
||||
const Padding(padding: EdgeInsets.symmetric(vertical: 20)),
|
||||
const Image(
|
||||
image: AssetImage('assets/images/logo-white.png'),
|
||||
width: 120,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 20.0),
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 94.0),
|
||||
child: Text(
|
||||
margin: const EdgeInsets.only(bottom: 20.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 94.0),
|
||||
child: const Text(
|
||||
'WGER',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
@@ -67,7 +67,7 @@ class AuthScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
const Flexible(
|
||||
//flex: deviceSize.width > 600 ? 2 : 1,
|
||||
child: AuthCard(),
|
||||
),
|
||||
@@ -174,7 +174,7 @@ class _AuthCardState extends State<AuthCard> {
|
||||
elevation: 8.0,
|
||||
child: Container(
|
||||
width: deviceSize.width * 0.75,
|
||||
padding: EdgeInsets.all(16.0),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: SingleChildScrollView(
|
||||
@@ -182,7 +182,7 @@ class _AuthCardState extends State<AuthCard> {
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
key: Key('inputUsername'),
|
||||
key: const Key('inputUsername'),
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).username,
|
||||
errorMaxLines: 2,
|
||||
@@ -206,7 +206,7 @@ class _AuthCardState extends State<AuthCard> {
|
||||
),
|
||||
if (_authMode == AuthMode.Signup)
|
||||
TextFormField(
|
||||
key: Key('inputEmail'),
|
||||
key: const Key('inputEmail'),
|
||||
decoration: InputDecoration(labelText: AppLocalizations.of(context).email),
|
||||
autofillHints: const [AutofillHints.email],
|
||||
controller: _emailController,
|
||||
@@ -243,7 +243,7 @@ class _AuthCardState extends State<AuthCard> {
|
||||
),
|
||||
if (_authMode == AuthMode.Signup)
|
||||
TextFormField(
|
||||
key: Key('inputPassword2'),
|
||||
key: const Key('inputPassword2'),
|
||||
decoration:
|
||||
InputDecoration(labelText: AppLocalizations.of(context).confirmPassword),
|
||||
controller: _password2Controller,
|
||||
@@ -267,7 +267,7 @@ class _AuthCardState extends State<AuthCard> {
|
||||
Flexible(
|
||||
flex: 3,
|
||||
child: TextFormField(
|
||||
key: Key('inputServer'),
|
||||
key: const Key('inputServer'),
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).customServerUrl,
|
||||
helperText: AppLocalizations.of(context).customServerHint,
|
||||
@@ -292,7 +292,7 @@ class _AuthCardState extends State<AuthCard> {
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Column(
|
||||
@@ -310,14 +310,14 @@ class _AuthCardState extends State<AuthCard> {
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
if (_isLoading)
|
||||
CircularProgressIndicator()
|
||||
const CircularProgressIndicator()
|
||||
else
|
||||
ElevatedButton(
|
||||
key: Key('actionButton'),
|
||||
key: const Key('actionButton'),
|
||||
child: Text(_authMode == AuthMode.Login
|
||||
? AppLocalizations.of(context).login
|
||||
: AppLocalizations.of(context).register),
|
||||
@@ -326,7 +326,7 @@ class _AuthCardState extends State<AuthCard> {
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
key: Key('toggleActionButton'),
|
||||
key: const Key('toggleActionButton'),
|
||||
child: Text(
|
||||
_authMode == AuthMode.Login
|
||||
? AppLocalizations.of(context).registerInstead.toUpperCase()
|
||||
@@ -338,7 +338,7 @@ class _AuthCardState extends State<AuthCard> {
|
||||
child: Text(_hideCustomServer
|
||||
? AppLocalizations.of(context).useCustomServer
|
||||
: AppLocalizations.of(context).useDefaultServer),
|
||||
key: Key('toggleCustomServerButton'),
|
||||
key: const Key('toggleCustomServerButton'),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_hideCustomServer = !_hideCustomServer;
|
||||
|
||||
@@ -41,7 +41,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
DashboardWorkoutWidget(),
|
||||
DashboardNutritionWidget(),
|
||||
DashboardWeightWidget(),
|
||||
DashboardCalendarWidget(),
|
||||
const DashboardCalendarWidget(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -51,7 +51,7 @@ class GalleryScreen extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
body: Consumer<GalleryProvider>(
|
||||
builder: (context, workoutProvider, child) => Gallery(),
|
||||
builder: (context, workoutProvider, child) => const Gallery(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
WorkoutPlansScreen(),
|
||||
NutritionScreen(),
|
||||
WeightScreen(),
|
||||
GalleryScreen(),
|
||||
const GalleryScreen(),
|
||||
];
|
||||
|
||||
/// Load initial data from the server
|
||||
@@ -146,26 +146,26 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.dashboard),
|
||||
icon: const Icon(Icons.dashboard),
|
||||
label: AppLocalizations.of(context).labelDashboard,
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.fitness_center),
|
||||
icon: const Icon(Icons.fitness_center),
|
||||
label: AppLocalizations.of(context).labelBottomNavWorkout,
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.restaurant),
|
||||
icon: const Icon(Icons.restaurant),
|
||||
label: AppLocalizations.of(context).labelBottomNavNutrition,
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: FaIcon(
|
||||
icon: const FaIcon(
|
||||
FontAwesomeIcons.weight,
|
||||
size: 20,
|
||||
),
|
||||
label: AppLocalizations.of(context).weight,
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.photo_library),
|
||||
icon: const Icon(Icons.photo_library),
|
||||
label: AppLocalizations.of(context).gallery,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -53,7 +53,7 @@ class NutritionalPlanScreen extends StatelessWidget {
|
||||
pinned: true,
|
||||
actions: [
|
||||
PopupMenuButton<NutritionalPlanOptions>(
|
||||
icon: Icon(Icons.more_vert),
|
||||
icon: const Icon(Icons.more_vert),
|
||||
onSelected: (value) {
|
||||
// Edit
|
||||
if (value == NutritionalPlanOptions.edit) {
|
||||
@@ -90,7 +90,7 @@ class NutritionalPlanScreen extends StatelessWidget {
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
title: Text(_nutritionalPlan.description),
|
||||
background: Image(
|
||||
background: const Image(
|
||||
image: AssetImage('assets/images/backgrounds/nutritional_plans.jpg'),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
@@ -103,7 +103,7 @@ class NutritionalPlanScreen extends StatelessWidget {
|
||||
? SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
|
||||
@@ -21,7 +21,7 @@ import 'package:flutter/material.dart';
|
||||
class SplashScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: Text('Loading...'),
|
||||
),
|
||||
|
||||
@@ -79,14 +79,14 @@ class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
|
||||
pinned: true,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
title: Text(workoutPlan.name),
|
||||
background: Image(
|
||||
background: const Image(
|
||||
image: AssetImage('assets/images/backgrounds/workout_plans.jpg'),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
PopupMenuButton<WorkoutOptions>(
|
||||
icon: Icon(Icons.more_vert),
|
||||
icon: const Icon(Icons.more_vert),
|
||||
onSelected: (value) {
|
||||
// Edit
|
||||
if (value == WorkoutOptions.edit) {
|
||||
@@ -130,7 +130,7 @@ class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
|
||||
@@ -66,8 +66,8 @@ final ThemeData wgerTheme = ThemeData(
|
||||
* Text theme
|
||||
*/
|
||||
textTheme: TextTheme(
|
||||
headline1: TextStyle(fontFamily: 'OpenSansLight', color: Colors.black),
|
||||
headline2: TextStyle(fontFamily: 'OpenSansLight', color: Colors.black),
|
||||
headline1: const TextStyle(fontFamily: 'OpenSansLight', color: Colors.black),
|
||||
headline2: const TextStyle(fontFamily: 'OpenSansLight', color: Colors.black),
|
||||
headline3: TextStyle(
|
||||
fontSize: materialSizes['h3']! * 0.8,
|
||||
fontFamily: 'OpenSansBold',
|
||||
@@ -102,7 +102,7 @@ final ThemeData wgerTheme = ThemeData(
|
||||
style: OutlinedButton.styleFrom(
|
||||
primary: wgerPrimaryButtonColor,
|
||||
visualDensity: VisualDensity.compact,
|
||||
side: BorderSide(color: wgerPrimaryButtonColor),
|
||||
side: const BorderSide(color: wgerPrimaryButtonColor),
|
||||
),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
@@ -114,7 +114,7 @@ final ThemeData wgerTheme = ThemeData(
|
||||
/*
|
||||
* Forms, etc.
|
||||
*/
|
||||
sliderTheme: SliderThemeData(
|
||||
sliderTheme: const SliderThemeData(
|
||||
activeTrackColor: wgerPrimaryButtonColor,
|
||||
thumbColor: wgerPrimaryColor,
|
||||
),
|
||||
|
||||
@@ -33,12 +33,12 @@ class AppDrawer extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
AppBar(
|
||||
title: Text('wger'),
|
||||
title: const Text('wger'),
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
ListTile(
|
||||
//dense: true,
|
||||
leading: Icon(Icons.exit_to_app),
|
||||
leading: const Icon(Icons.exit_to_app),
|
||||
title: Text(AppLocalizations.of(context).logout),
|
||||
onTap: () {
|
||||
Provider.of<AuthProvider>(context, listen: false).logout();
|
||||
|
||||
+14
-14
@@ -37,7 +37,7 @@ class WgerAboutListTile extends StatelessWidget {
|
||||
|
||||
return AboutListTile(
|
||||
//dense: true,
|
||||
icon: Icon(Icons.info),
|
||||
icon: const Icon(Icons.info),
|
||||
applicationName: 'wger',
|
||||
applicationVersion: 'App: ${authProvider.applicationVersion!.version}\n'
|
||||
'Server: ${authProvider.serverVersion}',
|
||||
@@ -51,17 +51,17 @@ class WgerAboutListTile extends StatelessWidget {
|
||||
),
|
||||
|
||||
aboutBoxChildren: [
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
Text(AppLocalizations.of(context).aboutDescription),
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
ListTile(
|
||||
leading: Icon(Icons.code),
|
||||
leading: const Icon(Icons.code),
|
||||
title: Text(AppLocalizations.of(context).aboutSourceTitle),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).aboutSourceText),
|
||||
Text(
|
||||
const Text(
|
||||
'https://github.com/wger-project',
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
@@ -70,15 +70,15 @@ class WgerAboutListTile extends StatelessWidget {
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () async => _launchURL('https://github.com/wger-project', context),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
ListTile(
|
||||
leading: Icon(Icons.bug_report),
|
||||
leading: const Icon(Icons.bug_report),
|
||||
title: Text(AppLocalizations.of(context).aboutBugsTitle),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).aboutBugsText),
|
||||
Text(
|
||||
const Text(
|
||||
'https://github.com/wger-project/flutter/issues/new/choose',
|
||||
style: TextStyle(color: Colors.blue),
|
||||
)
|
||||
@@ -88,15 +88,15 @@ class WgerAboutListTile extends StatelessWidget {
|
||||
onTap: () async =>
|
||||
_launchURL('https://github.com/wger-project/flutter/issues/new/choose', context),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
ListTile(
|
||||
leading: Icon(Icons.chat),
|
||||
leading: const Icon(Icons.chat),
|
||||
title: Text(AppLocalizations.of(context).aboutContactUsTitle),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).aboutContactUsText),
|
||||
Text(
|
||||
const Text(
|
||||
'https://discord.gg/rPWFv6W',
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
@@ -105,15 +105,15 @@ class WgerAboutListTile extends StatelessWidget {
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () async => _launchURL('https://discord.gg/rPWFv6W', context),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
ListTile(
|
||||
leading: Icon(Icons.translate),
|
||||
leading: const Icon(Icons.translate),
|
||||
title: Text(AppLocalizations.of(context).aboutTranslationTitle),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).aboutTranslationText),
|
||||
Text(
|
||||
const Text(
|
||||
'https://hosted.weblate.org/engage/wger/',
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
|
||||
@@ -57,10 +57,10 @@ class WgerAppBar extends StatelessWidget with PreferredSizeWidget {
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Divider(),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
//dense: true,
|
||||
leading: Icon(Icons.exit_to_app),
|
||||
leading: const Icon(Icons.exit_to_app),
|
||||
title: Text(AppLocalizations.of(context).logout),
|
||||
onTap: () {
|
||||
Provider.of<AuthProvider>(context, listen: false).logout();
|
||||
@@ -84,5 +84,5 @@ class WgerAppBar extends StatelessWidget with PreferredSizeWidget {
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => Size.fromHeight(kToolbarHeight);
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class MeasurementChartWidget extends StatelessWidget {
|
||||
],
|
||||
defaultRenderer: charts.LineRendererConfig(includePoints: true),
|
||||
primaryMeasureAxis: charts.NumericAxisSpec(
|
||||
tickProviderSpec: charts.BasicNumericTickProviderSpec(zeroBound: false),
|
||||
tickProviderSpec: const charts.BasicNumericTickProviderSpec(zeroBound: false),
|
||||
tickFormatterSpec: unitTickFormatter,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -32,7 +32,7 @@ class MutedText extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
_text,
|
||||
style: TextStyle(color: wgerTextMuted),
|
||||
style: const TextStyle(color: wgerTextMuted),
|
||||
textAlign: textAlign,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -217,14 +217,14 @@ class _DashboardCalendarWidgetState extends State<DashboardCalendarWidget>
|
||||
AppLocalizations.of(context).calendar,
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
leading: Icon(
|
||||
leading: const Icon(
|
||||
Icons.calendar_today_outlined,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
TableCalendar<Event>(
|
||||
locale: Localizations.localeOf(context).languageCode,
|
||||
firstDay: DateTime.now().subtract(Duration(days: 1000)),
|
||||
firstDay: DateTime.now().subtract(const Duration(days: 1000)),
|
||||
lastDay: DateTime.now(),
|
||||
focusedDay: _focusedDay,
|
||||
selectedDayPredicate: (day) => isSameDay(_selectedDay, day),
|
||||
|
||||
@@ -71,7 +71,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
Expanded(
|
||||
child: Text(
|
||||
meal.time!.format(context),
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
//textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
@@ -81,19 +81,19 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
children: [
|
||||
MutedText(
|
||||
'${meal.nutritionalValues.energy.toStringAsFixed(0)}${AppLocalizations.of(context).kcal}'),
|
||||
MutedText(' / '),
|
||||
const MutedText(' / '),
|
||||
MutedText(
|
||||
'${meal.nutritionalValues.protein.toStringAsFixed(0)}${AppLocalizations.of(context).g}'),
|
||||
MutedText(' / '),
|
||||
const MutedText(' / '),
|
||||
MutedText(
|
||||
'${meal.nutritionalValues.carbohydrates.toStringAsFixed(0)}${AppLocalizations.of(context).g}'),
|
||||
MutedText(' / '),
|
||||
const MutedText(' / '),
|
||||
MutedText(
|
||||
'${meal.nutritionalValues.fat.toStringAsFixed(0)}${AppLocalizations.of(context).g} '),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.history_edu),
|
||||
icon: const Icon(Icons.history_edu),
|
||||
color: wgerPrimaryButtonColor,
|
||||
onPressed: () {
|
||||
Provider.of<NutritionPlansProvider>(context, listen: false).logMealToDiary(meal);
|
||||
@@ -110,7 +110,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
],
|
||||
),
|
||||
);
|
||||
out.add(SizedBox(height: 5));
|
||||
out.add(const SizedBox(height: 5));
|
||||
|
||||
if (_showDetail) {
|
||||
for (final item in meal.mealItems) {
|
||||
@@ -126,7 +126,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
const SizedBox(width: 5),
|
||||
Text('${item.amount.toStringAsFixed(0)} ${AppLocalizations.of(context).g}'),
|
||||
],
|
||||
),
|
||||
@@ -134,9 +134,9 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
),
|
||||
);
|
||||
}
|
||||
out.add(SizedBox(height: 10));
|
||||
out.add(const SizedBox(height: 10));
|
||||
}
|
||||
out.add(Divider());
|
||||
out.add(const Divider());
|
||||
}
|
||||
|
||||
return out;
|
||||
@@ -144,10 +144,10 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
|
||||
Widget getTrailing() {
|
||||
if (!_hasContent) {
|
||||
return Text('');
|
||||
return const Text('');
|
||||
}
|
||||
|
||||
return _showDetail ? Icon(Icons.expand_less) : Icon(Icons.expand_more);
|
||||
return _showDetail ? const Icon(Icons.expand_less) : const Icon(Icons.expand_more);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -166,7 +166,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
.format(_plan!.creationDate)
|
||||
: '',
|
||||
),
|
||||
leading: Icon(
|
||||
leading: const Icon(
|
||||
Icons.restaurant,
|
||||
color: Colors.black,
|
||||
),
|
||||
@@ -179,12 +179,12 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
),
|
||||
if (_hasContent)
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
...getContent(),
|
||||
Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
padding: const EdgeInsets.all(15),
|
||||
height: 180,
|
||||
child: NutritionalPlanPieChartWidget(_plan!.nutritionalValues),
|
||||
)
|
||||
@@ -236,12 +236,12 @@ class _DashboardWeightWidgetState extends State<DashboardWeightWidget> {
|
||||
AppLocalizations.of(context).weight,
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
leading: FaIcon(
|
||||
leading: const FaIcon(
|
||||
FontAwesomeIcons.weight,
|
||||
color: Colors.black,
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.add),
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () async {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
@@ -260,7 +260,7 @@ class _DashboardWeightWidgetState extends State<DashboardWeightWidget> {
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
padding: const EdgeInsets.all(15),
|
||||
height: 180,
|
||||
child: MeasurementChartWidget(weightEntriesData.items
|
||||
.map((e) => MeasurementChartEntry(e.weight, e.date))
|
||||
@@ -312,10 +312,10 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
|
||||
Widget getTrailing() {
|
||||
if (!_hasContent) {
|
||||
return Text('');
|
||||
return const Text('');
|
||||
}
|
||||
|
||||
return _showDetail ? Icon(Icons.expand_less) : Icon(Icons.expand_more);
|
||||
return _showDetail ? const Icon(Icons.expand_less) : const Icon(Icons.expand_more);
|
||||
}
|
||||
|
||||
List<Widget> getContent() {
|
||||
@@ -333,7 +333,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
Expanded(
|
||||
child: Text(
|
||||
day.description,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
@@ -342,7 +342,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.play_arrow),
|
||||
icon: const Icon(Icons.play_arrow),
|
||||
color: wgerPrimaryButtonColor,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(GymModeScreen.routeName, arguments: day);
|
||||
@@ -366,11 +366,11 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(s.exerciseObj.name),
|
||||
SizedBox(width: 10),
|
||||
const SizedBox(width: 10),
|
||||
MutedText(set.getSmartRepr(s.exerciseObj).join('\n')),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
)
|
||||
: Container();
|
||||
@@ -379,7 +379,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
),
|
||||
));
|
||||
}
|
||||
out.add(Divider());
|
||||
out.add(const Divider());
|
||||
}
|
||||
|
||||
return out;
|
||||
@@ -401,7 +401,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
.format(_workoutPlan!.creationDate)
|
||||
: '',
|
||||
),
|
||||
leading: Icon(
|
||||
leading: const Icon(
|
||||
Icons.fitness_center_outlined,
|
||||
color: Colors.black,
|
||||
),
|
||||
@@ -414,7 +414,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
|
||||
),
|
||||
if (_hasContent)
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
...getContent(),
|
||||
|
||||
@@ -40,7 +40,7 @@ class ExerciseDetail extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
Text(_exercise.categoryObj.name),
|
||||
SizedBox(height: 8),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Equipment
|
||||
Text(
|
||||
@@ -49,8 +49,8 @@ class ExerciseDetail extends StatelessWidget {
|
||||
),
|
||||
if (_exercise.equipment.isNotEmpty)
|
||||
Text(_exercise.equipment.map((e) => e.name).toList().join('\n')),
|
||||
if (_exercise.equipment.isEmpty) Text('-/-'),
|
||||
SizedBox(height: 8),
|
||||
if (_exercise.equipment.isEmpty) const Text('-/-'),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Muscles
|
||||
Text(
|
||||
@@ -59,8 +59,8 @@ class ExerciseDetail extends StatelessWidget {
|
||||
),
|
||||
if (_exercise.muscles.isNotEmpty)
|
||||
Text(_exercise.muscles.map((e) => e.name).toList().join('\n')),
|
||||
if (_exercise.muscles.isEmpty) Text('-/-'),
|
||||
SizedBox(height: 8),
|
||||
if (_exercise.muscles.isEmpty) const Text('-/-'),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Muscles secondary
|
||||
Text(
|
||||
@@ -69,8 +69,8 @@ class ExerciseDetail extends StatelessWidget {
|
||||
),
|
||||
if (_exercise.musclesSecondary.isNotEmpty)
|
||||
Text(_exercise.musclesSecondary.map((e) => e.name).toList().join('\n')),
|
||||
if (_exercise.musclesSecondary.isEmpty) Text('-/-'),
|
||||
SizedBox(height: 8),
|
||||
if (_exercise.musclesSecondary.isEmpty) const Text('-/-'),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Description
|
||||
Text(
|
||||
@@ -78,7 +78,7 @@ class ExerciseDetail extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
Html(data: _exercise.description),
|
||||
SizedBox(height: 8),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -30,11 +30,11 @@ class ExerciseImageWidget extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return image != null
|
||||
? FadeInImage(
|
||||
placeholder: AssetImage('assets/images/placeholder.png'),
|
||||
placeholder: const AssetImage('assets/images/placeholder.png'),
|
||||
image: NetworkImage(image!.url),
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: Image(
|
||||
: const Image(
|
||||
image: AssetImage('assets/images/placeholder.png'),
|
||||
color: Color.fromRGBO(255, 255, 255, 0.3),
|
||||
colorBlendMode: BlendMode.modulate);
|
||||
|
||||
@@ -84,8 +84,8 @@ class _ImageFormState extends State<ImageForm> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).selectImage),
|
||||
SizedBox(height: 8),
|
||||
Icon(Icons.photo_camera),
|
||||
const SizedBox(height: 8),
|
||||
const Icon(Icons.photo_camera),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ class _ImageFormState extends State<ImageForm> {
|
||||
Navigator.of(context).pop();
|
||||
_showPicker(ImageSource.camera);
|
||||
},
|
||||
leading: Icon(Icons.photo_camera),
|
||||
leading: const Icon(Icons.photo_camera),
|
||||
title: Text(AppLocalizations.of(context).takePicture),
|
||||
),
|
||||
ListTile(
|
||||
@@ -120,7 +120,7 @@ class _ImageFormState extends State<ImageForm> {
|
||||
Navigator.of(context).pop();
|
||||
_showPicker(ImageSource.gallery);
|
||||
},
|
||||
leading: Icon(Icons.photo_library),
|
||||
leading: const Icon(Icons.photo_library),
|
||||
title: Text(AppLocalizations.of(context).chooseFromLibrary))
|
||||
],
|
||||
),
|
||||
@@ -132,10 +132,10 @@ class _ImageFormState extends State<ImageForm> {
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
key: Key('field-date'),
|
||||
key: const Key('field-date'),
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).date,
|
||||
suffixIcon: Icon(Icons.calendar_today_outlined),
|
||||
suffixIcon: const Icon(Icons.calendar_today_outlined),
|
||||
),
|
||||
readOnly: true, // Stop keyboard from appearing
|
||||
controller: dateController,
|
||||
@@ -165,7 +165,7 @@ class _ImageFormState extends State<ImageForm> {
|
||||
},
|
||||
),
|
||||
TextFormField(
|
||||
key: Key('field-description'),
|
||||
key: const Key('field-description'),
|
||||
decoration: InputDecoration(labelText: AppLocalizations.of(context).description),
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
@@ -175,7 +175,7 @@ class _ImageFormState extends State<ImageForm> {
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
key: Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
key: const Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
child: Text(AppLocalizations.of(context).save),
|
||||
onPressed: () async {
|
||||
// Validate and save
|
||||
|
||||
@@ -48,7 +48,7 @@ class Gallery extends StatelessWidget {
|
||||
builder: (context) => Material(
|
||||
child: Container(
|
||||
key: Key('image-${currentImage.id}-detail'),
|
||||
padding: EdgeInsets.all(10),
|
||||
padding: const EdgeInsets.all(10),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -68,14 +68,14 @@ class Gallery extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
icon: const Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
Provider.of<GalleryProvider>(context, listen: false)
|
||||
.deleteImage(currentImage);
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
IconButton(
|
||||
icon: Icon(Icons.edit),
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
@@ -98,7 +98,7 @@ class Gallery extends StatelessWidget {
|
||||
},
|
||||
child: FadeInImage(
|
||||
key: Key('image-${currentImage.id}'),
|
||||
placeholder: AssetImage('assets/images/placeholder.png'),
|
||||
placeholder: const AssetImage('assets/images/placeholder.png'),
|
||||
image: NetworkImage(currentImage.url!),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
|
||||
@@ -49,7 +49,7 @@ class CategoriesList extends StatelessWidget {
|
||||
),
|
||||
Container(
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.all(10),
|
||||
padding: const EdgeInsets.all(10),
|
||||
height: 220,
|
||||
child: MeasurementChartWidget(
|
||||
currentCategory.entries
|
||||
@@ -58,7 +58,7 @@ class CategoriesList extends StatelessWidget {
|
||||
unit: currentCategory.unit,
|
||||
),
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
@@ -82,7 +82,7 @@ class CategoriesList extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
icon: const Icon(Icons.add),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -38,7 +38,7 @@ class EntriesList extends StatelessWidget {
|
||||
return Column(children: [
|
||||
Container(
|
||||
color: Theme.of(context).cardColor,
|
||||
padding: EdgeInsets.all(10),
|
||||
padding: const EdgeInsets.all(10),
|
||||
height: 220,
|
||||
child: MeasurementChartWidget(
|
||||
_category.entries.map((e) => MeasurementChartEntry(e.value, e.date)).toList(),
|
||||
@@ -89,12 +89,12 @@ class EntriesList extends StatelessWidget {
|
||||
secondaryBackground: Container(
|
||||
color: Theme.of(context).errorColor,
|
||||
alignment: Alignment.centerRight,
|
||||
padding: EdgeInsets.only(right: 20),
|
||||
margin: EdgeInsets.symmetric(
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 4,
|
||||
),
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.delete,
|
||||
color: Colors.white,
|
||||
),
|
||||
@@ -102,12 +102,12 @@ class EntriesList extends StatelessWidget {
|
||||
background: Container(
|
||||
color: wgerPrimaryButtonColor,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.only(left: 20),
|
||||
margin: EdgeInsets.symmetric(
|
||||
padding: const EdgeInsets.only(left: 20),
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 4,
|
||||
),
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.edit,
|
||||
color: Colors.white,
|
||||
),
|
||||
|
||||
@@ -47,13 +47,13 @@ class MealForm extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(20),
|
||||
margin: const EdgeInsets.all(20),
|
||||
child: Form(
|
||||
key: _form,
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
key: Key('field-time'),
|
||||
key: const Key('field-time'),
|
||||
decoration: InputDecoration(labelText: AppLocalizations.of(context).time),
|
||||
controller: _timeController,
|
||||
onTap: () async {
|
||||
@@ -75,7 +75,7 @@ class MealForm extends StatelessWidget {
|
||||
),
|
||||
TextFormField(
|
||||
maxLength: 25,
|
||||
key: Key('field-name'),
|
||||
key: const Key('field-name'),
|
||||
decoration: InputDecoration(labelText: AppLocalizations.of(context).name),
|
||||
controller: _nameController,
|
||||
onSaved: (newValue) {
|
||||
@@ -84,7 +84,7 @@ class MealForm extends StatelessWidget {
|
||||
onFieldSubmitted: (_) {},
|
||||
),
|
||||
ElevatedButton(
|
||||
key: Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
key: const Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
child: Text(AppLocalizations.of(context).save),
|
||||
onPressed: () async {
|
||||
if (!_form.currentState!.validate()) {
|
||||
@@ -128,7 +128,7 @@ class MealItemForm extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(20),
|
||||
margin: const EdgeInsets.all(20),
|
||||
child: Form(
|
||||
key: _form,
|
||||
child: Column(
|
||||
@@ -225,7 +225,7 @@ class PlanForm extends StatelessWidget {
|
||||
children: [
|
||||
// Description
|
||||
TextFormField(
|
||||
key: Key('field-description'),
|
||||
key: const Key('field-description'),
|
||||
decoration: InputDecoration(labelText: AppLocalizations.of(context).description),
|
||||
controller: _descriptionController,
|
||||
onFieldSubmitted: (_) {},
|
||||
@@ -234,7 +234,7 @@ class PlanForm extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
key: Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
key: const Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
child: Text(AppLocalizations.of(context).save),
|
||||
onPressed: () async {
|
||||
// Validate and save the current values to the weightEntry
|
||||
|
||||
@@ -51,7 +51,7 @@ class _MealWidgetState extends State<MealWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(3),
|
||||
padding: const EdgeInsets.all(3),
|
||||
child: Card(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -77,7 +77,7 @@ class _MealWidgetState extends State<MealWidget> {
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.delete),
|
||||
icon: const Icon(Icons.delete),
|
||||
),
|
||||
if (widget._meal.mealItems.isNotEmpty)
|
||||
Ink(
|
||||
@@ -113,11 +113,11 @@ class _MealWidgetState extends State<MealWidget> {
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.edit),
|
||||
icon: const Icon(Icons.edit),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
...widget._meal.mealItems.map((item) => MealItemWidget(item, _expanded)).toList(),
|
||||
OutlinedButton(
|
||||
child: Text(AppLocalizations.of(context).addIngredient),
|
||||
@@ -159,7 +159,7 @@ class MealItemWidget extends StatelessWidget {
|
||||
final values = _item.nutritionalValues;
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -175,7 +175,7 @@ class MealItemWidget extends StatelessWidget {
|
||||
)),
|
||||
if (_expanded)
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
icon: const Icon(Icons.delete),
|
||||
iconSize: ICON_SIZE_SMALL,
|
||||
onPressed: () {
|
||||
// Delete the meal item
|
||||
@@ -221,7 +221,7 @@ class DismissibleMealHeader extends StatelessWidget {
|
||||
direction: DismissDirection.startToEnd,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(color: Colors.white),
|
||||
decoration: const BoxDecoration(color: Colors.white),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -240,7 +240,7 @@ class DismissibleMealHeader extends StatelessWidget {
|
||||
),
|
||||
IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: _expanded ? Icon(Icons.unfold_less) : Icon(Icons.unfold_more),
|
||||
icon: _expanded ? const Icon(Icons.unfold_less) : const Icon(Icons.unfold_more),
|
||||
onPressed: () {
|
||||
_toggle();
|
||||
},
|
||||
@@ -253,15 +253,15 @@ class DismissibleMealHeader extends StatelessWidget {
|
||||
background: Container(
|
||||
color: wgerPrimaryButtonColor, //Theme.of(context).primaryColor,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).logMeal,
|
||||
style: TextStyle(color: Colors.white),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
Icon(
|
||||
const Icon(
|
||||
Icons.history_edu,
|
||||
color: Colors.white,
|
||||
),
|
||||
|
||||
@@ -41,7 +41,7 @@ class NutritionalDiaryDetailWidget extends StatelessWidget {
|
||||
) {
|
||||
return Table(
|
||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
||||
border: TableBorder(
|
||||
border: const TableBorder(
|
||||
horizontalInside: BorderSide(width: 1, color: wgerTextMuted),
|
||||
),
|
||||
columnWidths: const {0: FractionColumnWidth(0.4)},
|
||||
@@ -52,20 +52,20 @@ class NutritionalDiaryDetailWidget extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(vertical: tablePadding),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).macronutrients,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
AppLocalizations.of(context).planned,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
AppLocalizations.of(context).logged,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
AppLocalizations.of(context).difference,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -177,9 +177,9 @@ class NutritionalDiaryDetailWidget extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
DateFormat.Hm(Localizations.localeOf(context).languageCode).format(log.datetime),
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -188,9 +188,9 @@ class NutritionalDiaryDetailWidget extends StatelessWidget {
|
||||
'${log.amount.toStringAsFixed(0)}${AppLocalizations.of(context).g} ${log.ingredientObj.name}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
const SizedBox(height: 4),
|
||||
...getMutedNutritionalValues(values, context),
|
||||
SizedBox(height: 12),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -199,7 +199,7 @@ class NutritionalDiaryDetailWidget extends StatelessWidget {
|
||||
Provider.of<NutritionPlansProvider>(context, listen: false)
|
||||
.deleteLog(log.id!, _nutritionalPlan.id!);
|
||||
},
|
||||
icon: Icon(Icons.delete_outline)),
|
||||
icon: const Icon(Icons.delete_outline)),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
@@ -212,7 +212,7 @@ class NutritionalDiaryDetailWidget extends StatelessWidget {
|
||||
final logs = _nutritionalPlan.getLogsForDate(_date);
|
||||
|
||||
if (valuesDate == null) {
|
||||
return Text('');
|
||||
return const Text('');
|
||||
}
|
||||
|
||||
return Column(
|
||||
@@ -221,7 +221,7 @@ class NutritionalDiaryDetailWidget extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
padding: const EdgeInsets.all(15),
|
||||
height: 220,
|
||||
child: NutritionalPlanPieChartWidget(valuesDate),
|
||||
),
|
||||
@@ -232,7 +232,7 @@ class NutritionalDiaryDetailWidget extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
const SizedBox(height: 15),
|
||||
...getEntriesTable(logs, context),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -47,7 +47,7 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
|
||||
return SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
..._nutritionalPlan.meals.map((meal) => MealWidget(meal)).toList(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -66,7 +66,7 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
padding: const EdgeInsets.all(15),
|
||||
height: 220,
|
||||
child: NutritionalPlanPieChartWidget(nutritionalValues),
|
||||
),
|
||||
@@ -74,7 +74,7 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Table(
|
||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
||||
border: TableBorder(
|
||||
border: const TableBorder(
|
||||
horizontalInside: BorderSide(width: 1, color: wgerTextMuted),
|
||||
),
|
||||
columnWidths: const {0: FractionColumnWidth(0.4)},
|
||||
@@ -85,20 +85,20 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(vertical: tablePadding),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).macronutrients,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
AppLocalizations.of(context).total,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
AppLocalizations.of(context).percentEnergy,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
AppLocalizations.of(context).gPerBodyKg,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -112,8 +112,8 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
|
||||
nutritionalValues.energy.toStringAsFixed(0) +
|
||||
AppLocalizations.of(context).kcal,
|
||||
),
|
||||
Text(''),
|
||||
Text(''),
|
||||
const Text(''),
|
||||
const Text(''),
|
||||
],
|
||||
),
|
||||
TableRow(
|
||||
@@ -148,8 +148,8 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
|
||||
),
|
||||
Text(nutritionalValues.carbohydratesSugar.toStringAsFixed(0) +
|
||||
AppLocalizations.of(context).g),
|
||||
Text(''),
|
||||
Text(''),
|
||||
const Text(''),
|
||||
const Text(''),
|
||||
],
|
||||
),
|
||||
TableRow(
|
||||
@@ -171,8 +171,8 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
|
||||
),
|
||||
Text(nutritionalValues.fatSaturated.toStringAsFixed(0) +
|
||||
AppLocalizations.of(context).g),
|
||||
Text(''),
|
||||
Text(''),
|
||||
const Text(''),
|
||||
const Text(''),
|
||||
],
|
||||
),
|
||||
TableRow(
|
||||
@@ -183,8 +183,8 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
|
||||
),
|
||||
Text(nutritionalValues.fibres.toStringAsFixed(0) +
|
||||
AppLocalizations.of(context).g),
|
||||
Text(''),
|
||||
Text(''),
|
||||
const Text(''),
|
||||
const Text(''),
|
||||
],
|
||||
),
|
||||
TableRow(
|
||||
@@ -195,21 +195,21 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
|
||||
),
|
||||
Text(nutritionalValues.sodium.toStringAsFixed(0) +
|
||||
AppLocalizations.of(context).g),
|
||||
Text(''),
|
||||
Text(''),
|
||||
const Text(''),
|
||||
const Text(''),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(padding: const EdgeInsets.all(8.0)),
|
||||
const Padding(padding: EdgeInsets.all(8.0)),
|
||||
Text(
|
||||
AppLocalizations.of(context).nutritionalDiary,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
padding: const EdgeInsets.all(15),
|
||||
height: 220,
|
||||
child: NutritionalDiaryChartWidget(nutritionalPlan: _nutritionalPlan),
|
||||
),
|
||||
|
||||
@@ -80,12 +80,12 @@ class NutritionalPlansList extends StatelessWidget {
|
||||
background: Container(
|
||||
color: Theme.of(context).errorColor,
|
||||
alignment: Alignment.centerRight,
|
||||
padding: EdgeInsets.only(right: 20),
|
||||
margin: EdgeInsets.symmetric(
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 4,
|
||||
),
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.delete,
|
||||
color: Colors.white,
|
||||
),
|
||||
|
||||
@@ -36,7 +36,7 @@ class WeightEntriesList extends StatelessWidget {
|
||||
children: [
|
||||
Container(
|
||||
color: Theme.of(context).cardColor,
|
||||
padding: EdgeInsets.all(15),
|
||||
padding: const EdgeInsets.all(15),
|
||||
height: 220,
|
||||
child: MeasurementChartWidget(
|
||||
_weightProvider.items.map((e) => MeasurementChartEntry(e.weight, e.date)).toList()),
|
||||
@@ -50,7 +50,7 @@ class WeightEntriesList extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).measurements),
|
||||
Icon(Icons.chevron_right)
|
||||
const Icon(Icons.chevron_right)
|
||||
],
|
||||
)),
|
||||
Expanded(
|
||||
@@ -95,12 +95,12 @@ class WeightEntriesList extends StatelessWidget {
|
||||
secondaryBackground: Container(
|
||||
color: Theme.of(context).errorColor,
|
||||
alignment: Alignment.centerRight,
|
||||
padding: EdgeInsets.only(right: 20),
|
||||
margin: EdgeInsets.symmetric(
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 4,
|
||||
),
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.delete,
|
||||
color: Colors.white,
|
||||
),
|
||||
@@ -108,12 +108,12 @@ class WeightEntriesList extends StatelessWidget {
|
||||
background: Container(
|
||||
color: wgerPrimaryButtonColor,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.only(left: 20),
|
||||
margin: EdgeInsets.symmetric(
|
||||
padding: const EdgeInsets.only(left: 20),
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 4,
|
||||
),
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.edit,
|
||||
color: Colors.white,
|
||||
),
|
||||
|
||||
@@ -50,7 +50,7 @@ class WeightForm extends StatelessWidget {
|
||||
readOnly: true, // Stop keyboard from appearing
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).date,
|
||||
suffixIcon: Icon(Icons.calendar_today_outlined),
|
||||
suffixIcon: const Icon(Icons.calendar_today_outlined),
|
||||
),
|
||||
enableInteractiveSelection: false,
|
||||
controller: dateController,
|
||||
|
||||
@@ -55,7 +55,7 @@ class LogChartWidget extends StatelessWidget {
|
||||
);
|
||||
}),
|
||||
],
|
||||
primaryMeasureAxis: charts.NumericAxisSpec(
|
||||
primaryMeasureAxis: const charts.NumericAxisSpec(
|
||||
tickProviderSpec: charts.BasicNumericTickProviderSpec(zeroBound: false),
|
||||
),
|
||||
behaviors: [
|
||||
|
||||
@@ -118,7 +118,7 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
if (_expanded)
|
||||
IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: Icon(Icons.delete),
|
||||
icon: const Icon(Icons.delete),
|
||||
iconSize: ICON_SIZE_SMALL,
|
||||
onPressed: () {
|
||||
Provider.of<WorkoutPlansProvider>(context, listen: false).deleteSet(set);
|
||||
@@ -138,14 +138,14 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (_expanded)
|
||||
ReorderableDragStartListener(
|
||||
index: index,
|
||||
child: IconButton(
|
||||
child: const IconButton(
|
||||
icon: Icon(Icons.drag_handle),
|
||||
onPressed: null,
|
||||
),
|
||||
@@ -178,7 +178,7 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
widget._day,
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.delete),
|
||||
icon: const Icon(Icons.delete),
|
||||
),
|
||||
if (widget._day.sets.isNotEmpty)
|
||||
Ink(
|
||||
@@ -212,13 +212,13 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.edit),
|
||||
icon: const Icon(Icons.edit),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
ReorderableListView(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
buildDefaultDragHandles: false,
|
||||
onReorder: (_oldIndex, _newIndex) async {
|
||||
@@ -282,7 +282,7 @@ class DayHeaderDismissible extends StatelessWidget {
|
||||
direction: DismissDirection.startToEnd,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(color: Colors.white),
|
||||
decoration: const BoxDecoration(color: Colors.white),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -300,7 +300,7 @@ class DayHeaderDismissible extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: _expanded ? Icon(Icons.unfold_less) : Icon(Icons.unfold_more),
|
||||
icon: _expanded ? const Icon(Icons.unfold_less) : const Icon(Icons.unfold_more),
|
||||
onPressed: () {
|
||||
_toggle();
|
||||
},
|
||||
@@ -311,15 +311,15 @@ class DayHeaderDismissible extends StatelessWidget {
|
||||
background: Container(
|
||||
color: wgerPrimaryButtonColor, //Theme.of(context).primaryColor,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).gymMode,
|
||||
style: TextStyle(color: Colors.white),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
Icon(
|
||||
const Icon(
|
||||
Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
),
|
||||
|
||||
@@ -55,7 +55,7 @@ class WorkoutForm extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
key: Key('field-name'),
|
||||
key: const Key('field-name'),
|
||||
decoration: InputDecoration(labelText: AppLocalizations.of(context).name),
|
||||
controller: workoutNameController,
|
||||
validator: (value) {
|
||||
@@ -72,7 +72,7 @@ class WorkoutForm extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
TextFormField(
|
||||
key: Key('field-description'),
|
||||
key: const Key('field-description'),
|
||||
decoration: InputDecoration(labelText: AppLocalizations.of(context).description),
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
@@ -91,7 +91,7 @@ class WorkoutForm extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
key: Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
key: const Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
child: Text(AppLocalizations.of(context).save),
|
||||
onPressed: () async {
|
||||
// Validate and save
|
||||
@@ -182,7 +182,7 @@ class _DayFormWidgetState extends State<DayFormWidget> {
|
||||
child: ListView(
|
||||
children: [
|
||||
TextFormField(
|
||||
key: Key('field-description'),
|
||||
key: const Key('field-description'),
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).description,
|
||||
helperText: AppLocalizations.of(context).dayDescriptionHelp,
|
||||
@@ -205,10 +205,10 @@ class _DayFormWidgetState extends State<DayFormWidget> {
|
||||
return null;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
...Day.weekdays.keys.map((dayNr) => DayCheckbox(dayNr, widget._day)).toList(),
|
||||
ElevatedButton(
|
||||
key: Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
key: const Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
child: Text(AppLocalizations.of(context).save),
|
||||
onPressed: () async {
|
||||
if (!_form.currentState!.validate()) {
|
||||
@@ -234,11 +234,11 @@ class _DayFormWidgetState extends State<DayFormWidget> {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text('An error occurred!'),
|
||||
content: Text('Something went wrong.'),
|
||||
title: const Text('An error occurred!'),
|
||||
content: const Text('Something went wrong.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text('Okay'),
|
||||
child: const Text('Okay'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
@@ -317,7 +317,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
child: ListView(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
color: wgerPrimaryColorLight,
|
||||
child: Column(
|
||||
//crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -356,14 +356,14 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
children: [
|
||||
Card(
|
||||
child: TypeAheadFormField(
|
||||
key: Key('field-typeahead'),
|
||||
key: const Key('field-typeahead'),
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
controller: _exercisesController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).searchExercise,
|
||||
prefixIcon: Icon(Icons.search),
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(Icons.help),
|
||||
icon: const Icon(Icons.help),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -372,7 +372,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).selectExercises),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
Text(AppLocalizations.of(context).sameRepetitions)
|
||||
],
|
||||
),
|
||||
@@ -440,7 +440,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).comment,
|
||||
@@ -459,7 +459,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
widget._set.comment = newValue!;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
...widget._set.exercisesObj.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final exercise = entry.value;
|
||||
@@ -477,21 +477,21 @@ class _SetFormWidgetState extends State<SetFormWidget> {
|
||||
removeExercise,
|
||||
),
|
||||
if (showSupersetInfo)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(3.0),
|
||||
child: Text('+'),
|
||||
),
|
||||
if (showSupersetInfo) Text(AppLocalizations.of(context).supersetWith),
|
||||
if (showSupersetInfo)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(3.0),
|
||||
child: Text('+'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
ElevatedButton(
|
||||
key: Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
key: const Key(SUBMIT_BUTTON_KEY_NAME),
|
||||
child: Text(AppLocalizations.of(context).save),
|
||||
onPressed: () async {
|
||||
final isValid = _formKey.currentState!.validate();
|
||||
@@ -574,7 +574,7 @@ class ExerciseSetting extends StatelessWidget {
|
||||
flex: 2,
|
||||
child: RepsInputWidget(setting, _detailed),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
flex: 3,
|
||||
child: RepetitionUnitInputWidget(setting),
|
||||
@@ -588,7 +588,7 @@ class ExerciseSetting extends StatelessWidget {
|
||||
flex: 2,
|
||||
child: WeightInputWidget(setting, _detailed),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
flex: 3,
|
||||
child: WeightUnitInputWidget(setting, key: Key(i.toString())),
|
||||
@@ -599,7 +599,7 @@ class ExerciseSetting extends StatelessWidget {
|
||||
flex: 2,
|
||||
child: RiRInputWidget(setting),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -612,11 +612,11 @@ class ExerciseSetting extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).setNr(i + 1),
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
const SizedBox(width: 10),
|
||||
Flexible(child: RepsInputWidget(setting, _detailed)),
|
||||
SizedBox(width: 4),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(child: WeightInputWidget(setting, _detailed)),
|
||||
],
|
||||
),
|
||||
@@ -644,12 +644,12 @@ class ExerciseSetting extends StatelessWidget {
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: ExerciseImageWidget(image: _exercise.getMainImage),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
icon: const Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
removeExercise(_exercise);
|
||||
}),
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
|
||||
//ExerciseImage(imageUrl: _exercise.images.first.url),
|
||||
if (!_detailed)
|
||||
|
||||
@@ -181,7 +181,7 @@ class StartPage extends StatelessWidget {
|
||||
_controller,
|
||||
exercisePages: _exercisePages,
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
@@ -197,7 +197,7 @@ class StartPage extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
...set.getSmartRepr(s.exerciseObj).map((e) => Text(e)).toList(),
|
||||
SizedBox(height: 15),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
@@ -211,7 +211,8 @@ class StartPage extends StatelessWidget {
|
||||
ElevatedButton(
|
||||
child: Text(AppLocalizations.of(context).start),
|
||||
onPressed: () {
|
||||
_controller.nextPage(duration: Duration(milliseconds: 200), curve: Curves.bounceIn);
|
||||
_controller.nextPage(
|
||||
duration: const Duration(milliseconds: 200), curve: Curves.bounceIn);
|
||||
},
|
||||
),
|
||||
NavigationFooter(
|
||||
@@ -290,7 +291,7 @@ class _LogPageState extends State<LogPage> {
|
||||
return Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
icon: const Icon(
|
||||
Icons.remove,
|
||||
color: Colors.black,
|
||||
),
|
||||
@@ -328,7 +329,7 @@ class _LogPageState extends State<LogPage> {
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
color: Colors.black,
|
||||
),
|
||||
@@ -348,7 +349,7 @@ class _LogPageState extends State<LogPage> {
|
||||
return Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
icon: const Icon(
|
||||
Icons.remove,
|
||||
color: Colors.black,
|
||||
),
|
||||
@@ -396,7 +397,7 @@ class _LogPageState extends State<LogPage> {
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
color: Colors.black,
|
||||
),
|
||||
@@ -429,7 +430,7 @@ class _LogPageState extends State<LogPage> {
|
||||
Row(
|
||||
children: [
|
||||
Flexible(child: getRepsWidget()),
|
||||
SizedBox(width: 8),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(child: getWeightWidget()),
|
||||
],
|
||||
),
|
||||
@@ -438,7 +439,7 @@ class _LogPageState extends State<LogPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(child: getRepsWidget()),
|
||||
SizedBox(width: 8),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(child: RepetitionUnitInputWidget(widget._log)),
|
||||
],
|
||||
),
|
||||
@@ -447,7 +448,7 @@ class _LogPageState extends State<LogPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(child: getWeightWidget()),
|
||||
SizedBox(width: 8),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(child: WeightUnitInputWidget(widget._log))
|
||||
],
|
||||
),
|
||||
@@ -464,7 +465,7 @@ class _LogPageState extends State<LogPage> {
|
||||
ElevatedButton(
|
||||
child: (!_isSaving)
|
||||
? Text(AppLocalizations.of(context).save)
|
||||
: SizedBox(
|
||||
: const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
@@ -488,7 +489,7 @@ class _LogPageState extends State<LogPage> {
|
||||
.addLog(widget._log);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
duration: Duration(seconds: 2), // default is 4
|
||||
duration: const Duration(seconds: 2), // default is 4
|
||||
content: Text(
|
||||
AppLocalizations.of(context).successfullySaved,
|
||||
textAlign: TextAlign.center,
|
||||
@@ -527,7 +528,7 @@ class _LogPageState extends State<LogPage> {
|
||||
title: Text(log.singleLogRepTextNoNl),
|
||||
subtitle:
|
||||
Text(DateFormat.yMd(Localizations.localeOf(context).languageCode).format(log.date)),
|
||||
trailing: Icon(Icons.copy),
|
||||
trailing: const Icon(Icons.copy),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
// Text field
|
||||
@@ -544,7 +545,7 @@ class _LogPageState extends State<LogPage> {
|
||||
.showSnackBar(SnackBar(content: Text(AppLocalizations.of(context).dataCopied)));
|
||||
});
|
||||
},
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 40),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 40),
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
@@ -576,9 +577,9 @@ class _LogPageState extends State<LogPage> {
|
||||
(key) => Row(
|
||||
children: [
|
||||
Text(groupedPlates[key].toString()),
|
||||
Text('×'),
|
||||
const Text('×'),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
decoration: const BoxDecoration(
|
||||
color: wgerPrimaryColorLight,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
@@ -591,13 +592,13 @@ class _LogPageState extends State<LogPage> {
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
key.toString(),
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -606,7 +607,7 @@ class _LogPageState extends State<LogPage> {
|
||||
)
|
||||
: MutedText(AppLocalizations.of(context).plateCalculatorNotDivisible),
|
||||
),
|
||||
SizedBox(height: 3),
|
||||
const SizedBox(height: 3),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -632,7 +633,7 @@ class _LogPageState extends State<LogPage> {
|
||||
widget._set.comment,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
child: (widget._workoutPlan.filterLogsByExercise(widget._exercise).isNotEmpty)
|
||||
? getPastLogs()
|
||||
@@ -675,10 +676,10 @@ class ExerciseOverview extends StatelessWidget {
|
||||
_controller,
|
||||
exercisePages: _exercisePages,
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
children: [
|
||||
Text(
|
||||
_exercise.categoryObj.name,
|
||||
@@ -762,7 +763,7 @@ class _SessionPageState extends State<SessionPage> {
|
||||
widget._controller,
|
||||
exercisePages: widget._exercisePages,
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
Expanded(child: Container()),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
@@ -850,7 +851,7 @@ class _SessionPageState extends State<SessionPage> {
|
||||
return null;
|
||||
}),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
const SizedBox(width: 10),
|
||||
Flexible(
|
||||
child: TextFormField(
|
||||
decoration:
|
||||
@@ -1008,7 +1009,7 @@ class NavigationFooter extends StatelessWidget {
|
||||
children: [
|
||||
if (showPrevious)
|
||||
IconButton(
|
||||
icon: Icon(Icons.chevron_left),
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
onPressed: () {
|
||||
_controller.previousPage(
|
||||
duration: DEFAULT_ANIMATION_DURATION,
|
||||
@@ -1017,17 +1018,17 @@ class NavigationFooter extends StatelessWidget {
|
||||
},
|
||||
)
|
||||
else
|
||||
SizedBox(width: 48),
|
||||
const SizedBox(width: 48),
|
||||
Expanded(
|
||||
child: LinearProgressIndicator(
|
||||
minHeight: 1.5,
|
||||
value: _ratioCompleted,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(wgerPrimaryColor),
|
||||
valueColor: const AlwaysStoppedAnimation<Color>(wgerPrimaryColor),
|
||||
),
|
||||
),
|
||||
if (showNext)
|
||||
IconButton(
|
||||
icon: Icon(Icons.chevron_right),
|
||||
icon: const Icon(Icons.chevron_right),
|
||||
onPressed: () {
|
||||
_controller.nextPage(
|
||||
duration: DEFAULT_ANIMATION_DURATION,
|
||||
@@ -1036,7 +1037,7 @@ class NavigationFooter extends StatelessWidget {
|
||||
},
|
||||
)
|
||||
else
|
||||
SizedBox(width: 48),
|
||||
const SizedBox(width: 48),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -1066,7 +1067,7 @@ class NavigationHeader extends StatelessWidget {
|
||||
...exercisePages.keys.map((e) {
|
||||
return ListTile(
|
||||
title: Text(e),
|
||||
trailing: Icon(Icons.chevron_right),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () {
|
||||
_controller.animateToPage(
|
||||
exercisePages[e]!,
|
||||
@@ -1096,7 +1097,7 @@ class NavigationHeader extends StatelessWidget {
|
||||
return Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.close),
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
@@ -1112,7 +1113,7 @@ class NavigationHeader extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.menu),
|
||||
icon: const Icon(Icons.menu),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
|
||||
@@ -46,7 +46,7 @@ class ExerciseLogChart extends StatelessWidget {
|
||||
builder: (context, AsyncSnapshot<Map<String, dynamic>> snapshot) => SizedBox(
|
||||
height: 150,
|
||||
child: snapshot.connectionState == ConnectionState.waiting
|
||||
? Center(child: CircularProgressIndicator())
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: LogChartWidget(snapshot.data, _currentDate),
|
||||
),
|
||||
);
|
||||
@@ -69,7 +69,7 @@ class DayLogWidget extends StatelessWidget {
|
||||
DateFormat.yMd(Localizations.localeOf(context).languageCode).format(_date),
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
if (_session != null) Text('Session data here'),
|
||||
if (_session != null) const Text('Session data here'),
|
||||
..._exerciseData.keys.map((exercise) {
|
||||
return Column(
|
||||
children: [
|
||||
@@ -79,7 +79,7 @@ class DayLogWidget extends StatelessWidget {
|
||||
),
|
||||
..._exerciseData[exercise]!.map((log) => Text(log.singleLogRepTextNoNl)).toList(),
|
||||
ExerciseLogChart(exercise, _date),
|
||||
SizedBox(height: 30),
|
||||
const SizedBox(height: 30),
|
||||
],
|
||||
);
|
||||
}).toList()
|
||||
|
||||
@@ -168,7 +168,7 @@ class _WorkoutLogCalendarState extends State<WorkoutLogCalendar> {
|
||||
children: [
|
||||
TableCalendar(
|
||||
locale: Localizations.localeOf(context).languageCode,
|
||||
firstDay: DateTime.now().subtract(Duration(days: 1000)),
|
||||
firstDay: DateTime.now().subtract(const Duration(days: 1000)),
|
||||
lastDay: DateTime.now(),
|
||||
focusedDay: _focusedDay,
|
||||
selectedDayPredicate: (day) => isSameDay(_selectedDay, day),
|
||||
|
||||
@@ -83,12 +83,12 @@ class WorkoutPlansList extends StatelessWidget {
|
||||
background: Container(
|
||||
color: Theme.of(context).errorColor,
|
||||
alignment: Alignment.centerRight,
|
||||
padding: EdgeInsets.only(right: 20),
|
||||
margin: EdgeInsets.symmetric(
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 4,
|
||||
),
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.delete,
|
||||
color: Colors.white,
|
||||
),
|
||||
|
||||
+17
-17
@@ -37,7 +37,7 @@ void main() {
|
||||
builder: (ctx, auth, _) => MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: Locale('en'),
|
||||
locale: const Locale('en'),
|
||||
home: AuthScreen(),
|
||||
),
|
||||
),
|
||||
@@ -68,14 +68,14 @@ void main() {
|
||||
expect(find.text('LOGIN INSTEAD'), findsNothing);
|
||||
|
||||
// Check that the correct widgets are shown
|
||||
expect(find.byKey(Key('inputUsername')), findsOneWidget);
|
||||
expect(find.byKey(Key('inputEmail')), findsNothing);
|
||||
expect(find.byKey(Key('inputPassword')), findsOneWidget);
|
||||
expect(find.byKey(Key('inputServer')), findsNothing);
|
||||
expect(find.byKey(Key('inputPassword2')), findsNothing);
|
||||
expect(find.byKey(Key('actionButton')), findsOneWidget);
|
||||
expect(find.byKey(Key('toggleActionButton')), findsOneWidget);
|
||||
expect(find.byKey(Key('toggleCustomServerButton')), findsOneWidget);
|
||||
expect(find.byKey(const Key('inputUsername')), findsOneWidget);
|
||||
expect(find.byKey(const Key('inputEmail')), findsNothing);
|
||||
expect(find.byKey(const Key('inputPassword')), findsOneWidget);
|
||||
expect(find.byKey(const Key('inputServer')), findsNothing);
|
||||
expect(find.byKey(const Key('inputPassword2')), findsNothing);
|
||||
expect(find.byKey(const Key('actionButton')), findsOneWidget);
|
||||
expect(find.byKey(const Key('toggleActionButton')), findsOneWidget);
|
||||
expect(find.byKey(const Key('toggleCustomServerButton')), findsOneWidget);
|
||||
}, skip: true); // TODO(x): skipped because of technical problems:
|
||||
// either the provider wasn't found or, if the call was removed, the
|
||||
// localization data could not be loaded...
|
||||
@@ -83,7 +83,7 @@ void main() {
|
||||
testWidgets('Test the widgets on the auth screen, registration', (WidgetTester tester) async {
|
||||
// Wrap screen in material app so that the media query gets a context
|
||||
await tester.pumpWidget(MaterialApp(home: AuthScreen()));
|
||||
await tester.tap(find.byKey(Key('toggleActionButton')));
|
||||
await tester.tap(find.byKey(const Key('toggleActionButton')));
|
||||
|
||||
// Rebuild the widget after the state has changed.
|
||||
await tester.pump();
|
||||
@@ -91,12 +91,12 @@ void main() {
|
||||
expect(find.text('LOGIN INSTEAD'), findsOneWidget);
|
||||
|
||||
// Check that the correct widgets are shown
|
||||
expect(find.byKey(Key('inputUsername')), findsOneWidget);
|
||||
expect(find.byKey(Key('inputEmail')), findsOneWidget);
|
||||
expect(find.byKey(Key('inputPassword')), findsOneWidget);
|
||||
expect(find.byKey(Key('inputServer')), findsOneWidget);
|
||||
expect(find.byKey(Key('inputPassword2')), findsOneWidget);
|
||||
expect(find.byKey(Key('actionButton')), findsOneWidget);
|
||||
expect(find.byKey(Key('toggleActionButton')), findsOneWidget);
|
||||
expect(find.byKey(const Key('inputUsername')), findsOneWidget);
|
||||
expect(find.byKey(const Key('inputEmail')), findsOneWidget);
|
||||
expect(find.byKey(const Key('inputPassword')), findsOneWidget);
|
||||
expect(find.byKey(const Key('inputServer')), findsOneWidget);
|
||||
expect(find.byKey(const Key('inputPassword2')), findsOneWidget);
|
||||
expect(find.byKey(const Key('actionButton')), findsOneWidget);
|
||||
expect(find.byKey(const Key('toggleActionButton')), findsOneWidget);
|
||||
}, skip: true);
|
||||
}
|
||||
@@ -22,8 +22,8 @@ import 'package:wger/helpers/misc.dart';
|
||||
|
||||
void main() {
|
||||
test('Test the TimeOfDayExtension', () {
|
||||
final time1 = TimeOfDay(hour: 00, minute: 00);
|
||||
final time2 = TimeOfDay(hour: 23, minute: 59);
|
||||
const time1 = TimeOfDay(hour: 00, minute: 00);
|
||||
const time2 = TimeOfDay(hour: 23, minute: 59);
|
||||
|
||||
expect(time2.toMinutes(), 23 * 60 + 59);
|
||||
expect(time1.isAfter(time2), false);
|
||||
|
||||
@@ -58,16 +58,16 @@ void main() {
|
||||
|
||||
expect(find.byType(TextFormField), findsNWidgets(2));
|
||||
expect(find.text('A very cool image from the gym'), findsOneWidget);
|
||||
expect(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget);
|
||||
expect(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget);
|
||||
|
||||
// Date can only be edited via the datepicker
|
||||
await tester.tap(find.byKey(Key('field-date')));
|
||||
await tester.tap(find.byKey(const Key('field-date')));
|
||||
await tester.pump();
|
||||
await tester.tap(find.text('OK'));
|
||||
await tester.tap(find.text('15'), warnIfMissed: false);
|
||||
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
verifyNever(mockGalleryProvider.addImage(any, any));
|
||||
verify(mockGalleryProvider.editImage(any, any));
|
||||
|
||||
@@ -46,7 +46,7 @@ void main() {
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Gallery(),
|
||||
home: const Gallery(),
|
||||
routes: {
|
||||
FormScreen.routeName: (ctx) => FormScreen(),
|
||||
},
|
||||
@@ -63,11 +63,11 @@ void main() {
|
||||
testWidgets('Test opening the form for an existing image', (WidgetTester tester) async {
|
||||
await mockNetworkImagesFor(() => tester.pumpWidget(createScreen()));
|
||||
|
||||
await tester.tap(find.byKey(Key('image-1')));
|
||||
await tester.tap(find.byKey(const Key('image-1')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Detail dialog opens
|
||||
expect(find.byKey(Key('image-1-detail')), findsOneWidget);
|
||||
expect(find.byKey(const Key('image-1-detail')), findsOneWidget);
|
||||
expect(find.byType(Image), findsNWidgets(5)); // four in the overview, one in the popup
|
||||
expect(find.text('A very cool image from the gym'), findsOneWidget);
|
||||
expect(find.byIcon(Icons.edit), findsOneWidget);
|
||||
@@ -84,7 +84,7 @@ void main() {
|
||||
|
||||
testWidgets('Tests the localization of dates - EN', (WidgetTester tester) async {
|
||||
await mockNetworkImagesFor(() => tester.pumpWidget(createScreen()));
|
||||
await tester.tap(find.byKey(Key('image-1')));
|
||||
await tester.tap(find.byKey(const Key('image-1')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('5/30/2021'), findsOneWidget);
|
||||
@@ -92,7 +92,7 @@ void main() {
|
||||
|
||||
testWidgets('Tests the localization of dates - DE', (WidgetTester tester) async {
|
||||
await mockNetworkImagesFor(() => tester.pumpWidget(createScreen(locale: 'de')));
|
||||
await tester.tap(find.byKey(Key('image-1')));
|
||||
await tester.tap(find.byKey(const Key('image-1')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('30.5.2021'), findsOneWidget);
|
||||
|
||||
@@ -96,7 +96,7 @@ void main() {
|
||||
expect(find.byIcon(Icons.menu), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||
await tester.drag(find.byType(ExerciseOverview), Offset(-500.0, 0.0));
|
||||
await tester.drag(find.byType(ExerciseOverview), const Offset(-500.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
//
|
||||
@@ -127,7 +127,7 @@ void main() {
|
||||
expect(find.byType(RepetitionUnitInputWidget), findsOneWidget);
|
||||
expect(find.byType(WeightUnitInputWidget), findsOneWidget);
|
||||
expect(find.byType(RiRInputWidget), findsOneWidget);
|
||||
await tester.drag(find.byType(LogPage), Offset(-500.0, 0.0));
|
||||
await tester.drag(find.byType(LogPage), const Offset(-500.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
//
|
||||
@@ -148,7 +148,7 @@ void main() {
|
||||
expect(find.text('test exercise 1'), findsOneWidget);
|
||||
expect(find.byType(LogPage), findsOneWidget);
|
||||
expect(find.byType(Form), findsOneWidget);
|
||||
await tester.drag(find.byType(LogPage), Offset(-500.0, 0.0));
|
||||
await tester.drag(find.byType(LogPage), const Offset(-500.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
//
|
||||
|
||||
@@ -54,7 +54,7 @@ void main() {
|
||||
home: TextButton(
|
||||
onPressed: () => key.currentState!.push(
|
||||
MaterialPageRoute<void>(
|
||||
settings: RouteSettings(arguments: 1),
|
||||
settings: const RouteSettings(arguments: 1),
|
||||
builder: (_) => MeasurementEntriesScreen(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -34,11 +34,11 @@ void main() {
|
||||
);
|
||||
|
||||
const int tCategoryId = 1;
|
||||
final MeasurementCategory tMeasurementCategory =
|
||||
const MeasurementCategory tMeasurementCategory =
|
||||
MeasurementCategory(id: 1, name: 'Strength', unit: 'kN');
|
||||
final List<MeasurementCategory> tMeasurementCategories = [
|
||||
MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'),
|
||||
MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
const MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'),
|
||||
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
];
|
||||
final Map<String, dynamic> tMeasurementCategoriesMap =
|
||||
jsonDecode(fixture('measurement_categories.json'));
|
||||
@@ -160,7 +160,7 @@ void main() {
|
||||
notes: '',
|
||||
)
|
||||
]),
|
||||
MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
];
|
||||
|
||||
// act
|
||||
@@ -172,16 +172,16 @@ void main() {
|
||||
});
|
||||
|
||||
group('addCategory()', () {
|
||||
final MeasurementCategory tMeasurementCategoryWithoutId =
|
||||
const MeasurementCategory tMeasurementCategoryWithoutId =
|
||||
MeasurementCategory(id: null, name: 'Strength', unit: 'kN');
|
||||
final Map<String, dynamic> tMeasurementCategoryMap =
|
||||
jsonDecode(fixture('measurement_category.json'));
|
||||
final Map<String, dynamic> tMeasurementCategoryMapWithoutId =
|
||||
jsonDecode(fixture('measurement_category_without_id_to_json.json'));
|
||||
final List<MeasurementCategory> tMeasurementCategoriesAdded = [
|
||||
MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
|
||||
MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'),
|
||||
MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'),
|
||||
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
|
||||
const MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'),
|
||||
const MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'),
|
||||
];
|
||||
setUp(() {
|
||||
when(mockWgerBaseProvider.post(any, any))
|
||||
@@ -222,7 +222,7 @@ void main() {
|
||||
.thenAnswer((realInvocation) => Future.value(Response('', 200)));
|
||||
|
||||
final List<MeasurementCategory> tMeasurementCategoriesOneDeleted = [
|
||||
MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
];
|
||||
|
||||
// act
|
||||
@@ -267,8 +267,8 @@ void main() {
|
||||
test('should add the new MeasurementCategory and remove the old one', () async {
|
||||
// arrange
|
||||
final List<MeasurementCategory> tMeasurementCategoriesEdited = [
|
||||
MeasurementCategory(id: 1, name: 'Triceps', unit: 'm'),
|
||||
MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
|
||||
const MeasurementCategory(id: 1, name: 'Triceps', unit: 'm'),
|
||||
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
|
||||
];
|
||||
|
||||
// act
|
||||
@@ -342,7 +342,7 @@ void main() {
|
||||
),
|
||||
tMeasurementEntry
|
||||
]),
|
||||
MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
];
|
||||
|
||||
setUp(() async {
|
||||
@@ -419,7 +419,7 @@ void main() {
|
||||
notes: 'Some important notes',
|
||||
),
|
||||
]),
|
||||
MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
];
|
||||
|
||||
setUp(() async {
|
||||
@@ -481,7 +481,7 @@ void main() {
|
||||
notes: '',
|
||||
),
|
||||
]),
|
||||
MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
];
|
||||
when(mockWgerBaseProvider.deleteRequest(any, any)).thenThrow(WgerHttpException('{}'));
|
||||
|
||||
@@ -530,7 +530,7 @@ void main() {
|
||||
notes: '',
|
||||
)
|
||||
]),
|
||||
MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
|
||||
];
|
||||
|
||||
// act
|
||||
|
||||
@@ -74,7 +74,7 @@ void main() {
|
||||
|
||||
expect(find.byType(TextFormField), findsNWidgets(2));
|
||||
expect(find.byType(ElevatedButton), findsOneWidget);
|
||||
expect(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget);
|
||||
expect(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Test editing an existing meal', (WidgetTester tester) async {
|
||||
@@ -93,9 +93,9 @@ void main() {
|
||||
reason: 'Time of existing meal is filled in',
|
||||
);
|
||||
|
||||
await tester.enterText(find.byKey(Key('field-time')), '12:34');
|
||||
await tester.enterText(find.byKey(Key('field-name')), 'test meal');
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.enterText(find.byKey(const Key('field-time')), '12:34');
|
||||
await tester.enterText(find.byKey(const Key('field-name')), 'test meal');
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
// Correct method was called
|
||||
verify(mockNutrition.editMeal(any));
|
||||
@@ -112,9 +112,9 @@ void main() {
|
||||
reason: 'Current time is filled in',
|
||||
);
|
||||
|
||||
await tester.enterText(find.byKey(Key('field-time')), '08:00');
|
||||
await tester.enterText(find.byKey(Key('field-name')), 'test meal');
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.enterText(find.byKey(const Key('field-time')), '08:00');
|
||||
await tester.enterText(find.byKey(const Key('field-name')), 'test meal');
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
// Correct method was called
|
||||
verifyNever(mockNutrition.editMeal(any));
|
||||
|
||||
@@ -74,7 +74,7 @@ void main() {
|
||||
|
||||
expect(find.byType(TextFormField), findsOneWidget);
|
||||
expect(find.byType(ElevatedButton), findsOneWidget);
|
||||
expect(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget);
|
||||
expect(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Test editing an existing nutritional plan', (WidgetTester tester) async {
|
||||
@@ -86,8 +86,8 @@ void main() {
|
||||
findsOneWidget,
|
||||
reason: 'Description of existing nutritional plan is filled in',
|
||||
);
|
||||
await tester.enterText(find.byKey(Key('field-description')), 'New description');
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.enterText(find.byKey(const Key('field-description')), 'New description');
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
// Correct method was called
|
||||
verify(mockNutrition.editPlan(any));
|
||||
@@ -112,8 +112,8 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text(''), findsOneWidget, reason: 'New nutritional plan has no description');
|
||||
await tester.enterText(find.byKey(Key('field-description')), 'New cool plan');
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.enterText(find.byKey(const Key('field-description')), 'New cool plan');
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
// Correct method was called
|
||||
verifyNever(mockNutrition.editPlan(any));
|
||||
|
||||
@@ -72,7 +72,7 @@ void main() {
|
||||
testWidgets('Test deleting an item by dragging the dismissible', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
|
||||
await tester.drag(find.byKey(Key('1')), Offset(-500.0, 0.0));
|
||||
await tester.drag(find.byKey(const Key('1')), const Offset(-500.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Confirmation dialog
|
||||
|
||||
@@ -24,8 +24,8 @@ import 'package:wger/models/workouts/weight_unit.dart';
|
||||
void main() {
|
||||
group('Test the singleSettingRepText method', () {
|
||||
test('Default rep and weight units, no RiR', () async {
|
||||
final repUnit = RepetitionUnit(id: 1, name: 'mol');
|
||||
final weightUnit = WeightUnit(id: 1, name: 'mg');
|
||||
const repUnit = RepetitionUnit(id: 1, name: 'mol');
|
||||
const weightUnit = WeightUnit(id: 1, name: 'mg');
|
||||
|
||||
final setting = Setting.empty();
|
||||
setting.reps = 2;
|
||||
@@ -37,8 +37,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('Default rep and weight units', () async {
|
||||
final repUnit = RepetitionUnit(id: 1, name: 'mol');
|
||||
final weightUnit = WeightUnit(id: 1, name: 'mg');
|
||||
const repUnit = RepetitionUnit(id: 1, name: 'mol');
|
||||
const weightUnit = WeightUnit(id: 1, name: 'mg');
|
||||
|
||||
final setting = Setting.empty();
|
||||
setting.reps = 2;
|
||||
@@ -50,8 +50,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('No weight, default rep and weight units', () async {
|
||||
final repUnit = RepetitionUnit(id: 1, name: 'mol');
|
||||
final weightUnit = WeightUnit(id: 1, name: 'mg');
|
||||
const repUnit = RepetitionUnit(id: 1, name: 'mol');
|
||||
const weightUnit = WeightUnit(id: 1, name: 'mg');
|
||||
|
||||
final setting = Setting.empty();
|
||||
setting.reps = 2;
|
||||
@@ -63,8 +63,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('Custom rep and weight units, no RiR', () async {
|
||||
final repUnit = RepetitionUnit(id: 2, name: 'mol');
|
||||
final weightUnit = WeightUnit(id: 2, name: 'mg');
|
||||
const repUnit = RepetitionUnit(id: 2, name: 'mol');
|
||||
const weightUnit = WeightUnit(id: 2, name: 'mg');
|
||||
|
||||
final setting = Setting.empty();
|
||||
setting.reps = 2;
|
||||
@@ -76,8 +76,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('Custom rep and weight units, RiR', () async {
|
||||
final repUnit = RepetitionUnit(id: 2, name: 'mol');
|
||||
final weightUnit = WeightUnit(id: 2, name: 'mg');
|
||||
const repUnit = RepetitionUnit(id: 2, name: 'mol');
|
||||
const weightUnit = WeightUnit(id: 2, name: 'mg');
|
||||
|
||||
final setting = Setting.empty();
|
||||
setting.reps = 2;
|
||||
|
||||
@@ -80,7 +80,7 @@ void main() {
|
||||
testWidgets('Test deleting an item by dragging the dismissible', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
|
||||
await tester.drag(find.byKey(Key('1')), Offset(-500.0, 0.0));
|
||||
await tester.drag(find.byKey(const Key('1')), const Offset(-500.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(ListTile), findsOneWidget);
|
||||
});
|
||||
|
||||
@@ -72,9 +72,9 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text(''), findsOneWidget, reason: 'New day has no description');
|
||||
await tester.enterText(find.byKey(Key('field-description')), 'Leg day!');
|
||||
await tester.tap(find.byKey(Key('field-checkbox-1')));
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.enterText(find.byKey(const Key('field-description')), 'Leg day!');
|
||||
await tester.tap(find.byKey(const Key('field-checkbox-1')));
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
verify(mockWorkoutPlans.addDay(any, any));
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ void main() {
|
||||
findsOneWidget,
|
||||
reason: 'Description of existing workout plan',
|
||||
);
|
||||
await tester.enterText(find.byKey(Key('field-name')), 'New description');
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.enterText(find.byKey(const Key('field-name')), 'New description');
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
// Correct method was called
|
||||
verify(mockWorkoutPlans.editWorkout(any));
|
||||
@@ -120,8 +120,8 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text(''), findsNWidgets(2), reason: 'New workout has no name or description');
|
||||
await tester.enterText(find.byKey(Key('field-name')), editWorkout.name);
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.enterText(find.byKey(const Key('field-name')), editWorkout.name);
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
verifyNever(mockWorkoutPlans.editWorkout(any));
|
||||
verify(mockWorkoutPlans.addWorkout(any));
|
||||
@@ -140,9 +140,9 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text(''), findsNWidgets(2), reason: 'New workout has no name or description');
|
||||
await tester.enterText(find.byKey(Key('field-name')), editWorkout.name);
|
||||
await tester.enterText(find.byKey(Key('field-description')), editWorkout.description);
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.enterText(find.byKey(const Key('field-name')), editWorkout.name);
|
||||
await tester.enterText(find.byKey(const Key('field-description')), editWorkout.description);
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
verifyNever(mockWorkoutPlans.editWorkout(any));
|
||||
verify(mockWorkoutPlans.addWorkout(any));
|
||||
|
||||
@@ -74,7 +74,7 @@ void main() {
|
||||
testWidgets('Test deleting an item by dragging the dismissible', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
|
||||
await tester.drag(find.byKey(Key('1')), Offset(-500.0, 0.0));
|
||||
await tester.drag(find.byKey(const Key('1')), const Offset(-500.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Confirmation dialog
|
||||
|
||||
@@ -81,7 +81,7 @@ void main() {
|
||||
expect(find.byType(TypeAheadFormField), findsOneWidget);
|
||||
expect(find.byType(Slider), findsOneWidget);
|
||||
//expect(find.byType(SwitchListTile), findsOneWidget);
|
||||
expect(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget);
|
||||
expect(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget);
|
||||
expect(find.byType(ElevatedButton), findsOneWidget);
|
||||
});
|
||||
|
||||
@@ -93,10 +93,10 @@ void main() {
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.enterText(find.byKey(Key('field-typeahead')), 'exercise');
|
||||
await tester.enterText(find.byKey(const Key('field-typeahead')), 'exercise');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
//verify(mockWorkoutPlans.addSet(any));
|
||||
//verify(mockWorkoutPlans.addSettinbg(any));
|
||||
|
||||
@@ -85,7 +85,7 @@ NutritionalPlan getNutritionalPlan() {
|
||||
final meal1 = Meal(
|
||||
id: 1,
|
||||
plan: 1,
|
||||
time: TimeOfDay(hour: 17, minute: 0),
|
||||
time: const TimeOfDay(hour: 17, minute: 0),
|
||||
name: 'Initial Name 1',
|
||||
);
|
||||
meal1.mealItems = [mealItem1, mealItem2];
|
||||
@@ -93,7 +93,7 @@ NutritionalPlan getNutritionalPlan() {
|
||||
final meal2 = Meal(
|
||||
id: 2,
|
||||
plan: 1,
|
||||
time: TimeOfDay(hour: 22, minute: 5),
|
||||
time: const TimeOfDay(hour: 22, minute: 5),
|
||||
name: 'Initial Name 2',
|
||||
);
|
||||
meal2.mealItems = [mealItem3];
|
||||
|
||||
Reference in new issue
Block a user