dart format --line-length=100 .

(except auto generated files)
This commit is contained in:
Dieter Plaetinck
2024-06-20 15:44:35 +03:00
parent b051220bf6
commit 6e1d3f9568
23 changed files with 98 additions and 165 deletions

View File

@@ -42,28 +42,22 @@ class NutritionalGoals {
// infer values where we can
if (energy == null) {
if (protein != null && carbohydrates != null && fat != null) {
energy = protein! * ENERGY_PROTEIN +
carbohydrates! * ENERGY_CARBOHYDRATES +
fat! * ENERGY_FAT;
energy =
protein! * ENERGY_PROTEIN + carbohydrates! * ENERGY_CARBOHYDRATES + fat! * ENERGY_FAT;
}
return;
}
// TODO: input validation when the user modifies/creates the plan, to assure energy is high enough
if (protein == null && carbohydrates != null && fat != null) {
protein = (energy! -
carbohydrates! * ENERGY_CARBOHYDRATES -
fat! * ENERGY_FAT) /
ENERGY_PROTEIN;
protein =
(energy! - carbohydrates! * ENERGY_CARBOHYDRATES - fat! * ENERGY_FAT) / ENERGY_PROTEIN;
assert(protein! > 0);
} else if (carbohydrates == null && protein != null && fat != null) {
carbohydrates =
(energy! - protein! * ENERGY_PROTEIN - fat! * ENERGY_FAT) /
ENERGY_CARBOHYDRATES;
(energy! - protein! * ENERGY_PROTEIN - fat! * ENERGY_FAT) / ENERGY_CARBOHYDRATES;
assert(carbohydrates! > 0);
} else if (fat == null && protein != null && carbohydrates != null) {
fat = (energy! -
protein! * ENERGY_PROTEIN -
carbohydrates! * ENERGY_CARBOHYDRATES) /
fat = (energy! - protein! * ENERGY_PROTEIN - carbohydrates! * ENERGY_CARBOHYDRATES) /
ENERGY_FAT;
assert(fat! > 0);
}
@@ -74,8 +68,7 @@ class NutritionalGoals {
energy: energy != null ? energy! / v : null,
protein: protein != null ? protein! / v : null,
carbohydrates: carbohydrates != null ? carbohydrates! / v : null,
carbohydratesSugar:
carbohydratesSugar != null ? carbohydratesSugar! / v : null,
carbohydratesSugar: carbohydratesSugar != null ? carbohydratesSugar! / v : null,
fat: fat != null ? fat! / v : null,
fatSaturated: fatSaturated != null ? fatSaturated! / v : null,
fiber: fiber != null ? fiber! / v : null,
@@ -84,10 +77,7 @@ class NutritionalGoals {
}
bool isComplete() {
return energy != null &&
protein != null &&
carbohydrates != null &&
fat != null;
return energy != null && protein != null && carbohydrates != null && fat != null;
}
/// Convert goals into values.
@@ -120,8 +110,7 @@ class NutritionalGoals {
goals.protein = (100 * protein! * ENERGY_PROTEIN) / energy!;
}
if (carbohydrates != null) {
goals.carbohydrates =
(100 * carbohydrates! * ENERGY_CARBOHYDRATES) / energy!;
goals.carbohydrates = (100 * carbohydrates! * ENERGY_CARBOHYDRATES) / energy!;
}
if (fat != null) {
goals.fat = (100 * fat! * ENERGY_FAT) / energy!;

View File

@@ -160,13 +160,8 @@ class _AddExerciseStepperState extends State<AddExerciseStepper> {
],
currentStep: _currentStep,
onStepContinue: () {
if (_keys[_currentStep]
.currentState
?.validate() ??
false) {
_keys[_currentStep]
.currentState
?.save();
if (_keys[_currentStep].currentState?.validate() ?? false) {
_keys[_currentStep].currentState?.save();
if (_currentStep != lastStepIndex) {
setState(() {
@@ -213,7 +208,7 @@ class EmailNotVerified extends StatelessWidget {
leading: const Icon(Icons.warning),
title: Text(AppLocalizations.of(context).unVerifiedEmail),
subtitle: Text(AppLocalizations.of(context)
.contributeExerciseWarning(MIN_ACCOUNT_AGE.toString())),
.contributeExerciseWarning(MIN_ACCOUNT_AGE.toString())),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,

View File

@@ -47,8 +47,8 @@ class _LogMealScreenState extends State<LogMealScreen> {
final args = ModalRoute.of(context)!.settings.arguments as LogMealArguments;
final meal = args.meal.copyWith(
mealItems: args.meal.mealItems
.map((mealItem) => mealItem.copyWith(amount: mealItem.amount * portionPct / 100))
.toList(),
.map((mealItem) => mealItem.copyWith(amount: mealItem.amount * portionPct / 100))
.toList(),
);
return Scaffold(

View File

@@ -124,7 +124,7 @@ class NutritionalPlanScreen extends StatelessWidget {
);
} else if (value == NutritionalPlanOptions.delete) {
Provider.of<NutritionPlansProvider>(context, listen: false)
.deletePlan(nutritionalPlan.id!);
.deletePlan(nutritionalPlan.id!);
Navigator.of(context).pop();
}
},
@@ -153,10 +153,7 @@ class NutritionalPlanScreen extends StatelessWidget {
titlePadding: const EdgeInsets.fromLTRB(56, 0, 56, 16),
title: Text(
nutritionalPlan.getLabel(context),
style: Theme.of(context)
.textTheme
.titleLarge
?.copyWith(color: appBarForeground),
style: Theme.of(context).textTheme.titleLarge?.copyWith(color: appBarForeground),
),
),
),

View File

@@ -31,9 +31,7 @@ class WeightScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final lastWeightEntry = context
.read<BodyWeightProvider>()
.getNewestEntry();
final lastWeightEntry = context.read<BodyWeightProvider>().getNewestEntry();
return Scaffold(
appBar: EmptyAppBar(AppLocalizations.of(context).weight),

View File

@@ -85,10 +85,7 @@ class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
titlePadding: const EdgeInsets.fromLTRB(56, 0, 56, 16),
title: Text(
workoutPlan.name,
style: Theme.of(context)
.textTheme
.titleLarge
?.copyWith(color: appBarForeground),
style: Theme.of(context).textTheme.titleLarge?.copyWith(color: appBarForeground),
),
),
actions: [
@@ -109,7 +106,7 @@ class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
// Delete
} else if (value == WorkoutOptions.delete) {
Provider.of<WorkoutPlansProvider>(context, listen: false)
.deleteWorkout(workoutPlan.id!);
.deleteWorkout(workoutPlan.id!);
Navigator.of(context).pop();
// Toggle Mode

View File

@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:flex_color_scheme/flex_color_scheme.dart';
import 'package:flutter/material.dart';
import 'package:table_calendar/table_calendar.dart';

View File

@@ -33,9 +33,8 @@ class _AddExerciseMultiselectButtonState<T> extends State<AddExerciseMultiselect
child: MultiSelectDialogField(
initialValue: widget.initialItems,
onSaved: widget.onSaved,
items: widget.items
.map((item) => MultiSelectItem<T>(item, widget.displayName(item)))
.toList(),
items:
widget.items.map((item) => MultiSelectItem<T>(item, widget.displayName(item))).toList(),
onConfirm: (value) {
setState(() {
_selectedItems = value.cast<T>();

View File

@@ -35,9 +35,8 @@ class PreviewExerciseImages extends StatelessWidget with ExerciseImagePickerMixi
),
child: IconButton(
iconSize: 20,
onPressed: () => context
.read<AddExerciseProvider>()
.removeExercise(file.path),
onPressed: () =>
context.read<AddExerciseProvider>().removeExercise(file.path),
color: Colors.white,
icon: const Icon(Icons.delete),
),

View File

@@ -61,38 +61,36 @@ class Step2Variations extends StatelessWidget {
),
),
// Exercise bases without variations
...exerciseProvider.exercises
.where((b) => b.variationId == null)
.map(
(base) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
Text(
base
.getExercise(
Localizations.localeOf(context).languageCode,
)
.name,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 20),
],
...exerciseProvider.exercises.where((b) => b.variationId == null).map(
(base) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
Text(
base
.getExercise(
Localizations.localeOf(context).languageCode,
)
.name,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 20),
],
),
),
),
Consumer<AddExerciseProvider>(
builder: (ctx, provider, __) => Switch(
value: provider.newVariationForExercise == base.id,
onChanged: (state) => provider.newVariationForExercise = base.id,
Consumer<AddExerciseProvider>(
builder: (ctx, provider, __) => Switch(
value: provider.newVariationForExercise == base.id,
onChanged: (state) => provider.newVariationForExercise = base.id,
),
),
),
],
],
),
),
),
],
),
),

View File

@@ -13,8 +13,7 @@ class Step5Images extends StatefulWidget {
State<Step5Images> createState() => _Step5ImagesState();
}
class _Step5ImagesState extends State<Step5Images>
with ExerciseImagePickerMixin {
class _Step5ImagesState extends State<Step5Images> with ExerciseImagePickerMixin {
@override
Widget build(BuildContext context) {
return Form(
@@ -34,8 +33,7 @@ class _Step5ImagesState extends State<Step5Images>
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
onPressed: () =>
pickImages(context, pickFromCamera: true),
onPressed: () => pickImages(context, pickFromCamera: true),
icon: const Icon(Icons.camera_alt),
),
IconButton(

View File

@@ -111,10 +111,7 @@ class AboutPage extends StatelessWidget {
SizedBox(height: 0.025 * deviceSize.height),
Text(
AppLocalizations.of(context).aboutDescription,
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(fontSize: 16),
style: Theme.of(context).textTheme.bodyMedium!.copyWith(fontSize: 16),
),
const SizedBox(height: 10),
AboutEntry(

View File

@@ -91,24 +91,12 @@ class MainAppBar extends StatelessWidget implements PreferredSizeWidget {
leading: const Icon(Icons.exit_to_app),
title: Text(AppLocalizations.of(context).logout),
onTap: () {
context
.read<AuthProvider>()
.logout();
context
.read<WorkoutPlansProvider>()
.clear();
context
.read<NutritionPlansProvider>()
.clear();
context
.read<BodyWeightProvider>()
.clear();
context
.read<GalleryProvider>()
.clear();
context
.read<UserProvider>()
.clear();
context.read<AuthProvider>().logout();
context.read<WorkoutPlansProvider>().clear();
context.read<NutritionPlansProvider>().clear();
context.read<BodyWeightProvider>().clear();
context.read<GalleryProvider>().clear();
context.read<UserProvider>().clear();
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed('/');

View File

@@ -50,9 +50,7 @@ class Pill extends StatelessWidget {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 7),
decoration: BoxDecoration(
color: Theme.of(context)
.primaryColorLight
.withOpacity(0.15),
color: Theme.of(context).primaryColorLight.withOpacity(0.15),
border: Border.all(color: Colors.grey[300]!),
borderRadius: BorderRadius.circular(5),
),

View File

@@ -34,8 +34,7 @@ class SettingsPage extends StatefulWidget {
class _SettingsPageState extends State<SettingsPage> {
@override
Widget build(BuildContext context) {
final exerciseProvider =
Provider.of<ExercisesProvider>(context, listen: false);
final exerciseProvider = Provider.of<ExercisesProvider>(context, listen: false);
return Scaffold(
appBar: AppBar(
@@ -46,8 +45,7 @@ class _SettingsPageState extends State<SettingsPage> {
ListTile(
// leading: const Icon(Icons.cached),
title: Text(AppLocalizations.of(context).settingsCacheTitle),
subtitle:
Text(AppLocalizations.of(context).settingsCacheDescription),
subtitle: Text(AppLocalizations.of(context).settingsCacheDescription),
trailing: IconButton(
key: const ValueKey('cacheIcon'),
icon: const Icon(Icons.delete),
@@ -56,8 +54,7 @@ class _SettingsPageState extends State<SettingsPage> {
if (context.mounted) {
final snackBar = SnackBar(
content: Text(AppLocalizations.of(context)
.settingsCacheDeletedSnackbar),
content: Text(AppLocalizations.of(context).settingsCacheDeletedSnackbar),
);
// Find the ScaffoldMessenger in the widget tree

View File

@@ -155,7 +155,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
subtitle: Text(
_hasContent
? DateFormat.yMd(Localizations.localeOf(context).languageCode)
.format(_plan!.creationDate)
.format(_plan!.creationDate)
: '',
),
leading: Icon(
@@ -285,8 +285,8 @@ class _DashboardWeightWidgetState extends State<DashboardWeightWidget> {
height: 200,
child: MeasurementChartWidgetFl(
weightProvider.items
.map((e) => MeasurementChartEntry(e.weight, e.date))
.toList(),
.map((e) => MeasurementChartEntry(e.weight, e.date))
.toList(),
unit: profile!.isMetric
? AppLocalizations.of(context).kg
: AppLocalizations.of(context).lb,
@@ -311,9 +311,7 @@ class _DashboardWeightWidgetState extends State<DashboardWeightWidget> {
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).newEntry,
WeightForm(weightProvider
.getNewestEntry()
?.copyWith(id: null)),
WeightForm(weightProvider.getNewestEntry()?.copyWith(id: null)),
),
);
},
@@ -352,10 +350,10 @@ class _DashboardMeasurementWidgetState extends State<DashboardMeasurementWidget>
final provider = Provider.of<MeasurementProvider>(context, listen: false);
final items = provider.categories
.map<Widget>(
(item) => CategoriesCard(item, elevation: 0),
)
.toList();
.map<Widget>(
(item) => CategoriesCard(item, elevation: 0),
)
.toList();
if (items.isNotEmpty) {
items.add(
NothingFound(
@@ -412,10 +410,7 @@ class _DashboardMeasurementWidgetState extends State<DashboardMeasurementWidget>
padding: const EdgeInsets.only(bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: items
.asMap()
.entries
.map((entry) {
children: items.asMap().entries.map((entry) {
return GestureDetector(
onTap: () => _controller.animateToPage(entry.key),
child: Container(
@@ -427,13 +422,10 @@ class _DashboardMeasurementWidgetState extends State<DashboardMeasurementWidget>
),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context)
.textTheme
.headlineSmall!
.color!
.withOpacity(
_current == entry.key ? 0.9 : 0.4,
),
color:
Theme.of(context).textTheme.headlineSmall!.color!.withOpacity(
_current == entry.key ? 0.9 : 0.4,
),
),
),
);
@@ -559,7 +551,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
subtitle: Text(
_hasContent
? DateFormat.yMd(Localizations.localeOf(context).languageCode)
.format(_workoutPlan!.creationDate)
.format(_workoutPlan!.creationDate)
: '',
),
leading: Icon(

View File

@@ -59,7 +59,7 @@ class Gallery extends StatelessWidget {
children: [
Text(
DateFormat.yMd(Localizations.localeOf(context).languageCode)
.format(currentImage.date),
.format(currentImage.date),
style: Theme.of(context).textTheme.headlineSmall,
),
Expanded(

View File

@@ -31,9 +31,7 @@ class CategoriesCard extends StatelessWidget {
padding: const EdgeInsets.all(10),
height: 220,
child: MeasurementChartWidgetFl(
currentCategory.entries
.map((e) => MeasurementChartEntry(e.value, e.date))
.toList(),
currentCategory.entries.map((e) => MeasurementChartEntry(e.value, e.date)).toList(),
unit: currentCategory.unit,
),
),

View File

@@ -39,9 +39,7 @@ class EntriesList extends StatelessWidget {
padding: const EdgeInsets.all(10),
height: 220,
child: MeasurementChartWidgetFl(
_category.entries
.map((e) => MeasurementChartEntry(e.value, e.date))
.toList(),
_category.entries.map((e) => MeasurementChartEntry(e.value, e.date)).toList(),
unit: _category.unit,
),
),
@@ -58,7 +56,7 @@ class EntriesList extends StatelessWidget {
title: Text('${currentEntry.value} ${_category.unit}'),
subtitle: Text(
DateFormat.yMd(Localizations.localeOf(context).languageCode)
.format(currentEntry.date),
.format(currentEntry.date),
),
trailing: PopupMenuButton(
itemBuilder: (BuildContext context) {

View File

@@ -237,11 +237,11 @@ class FlNutritionalPlanPieChartState extends State<FlNutritionalPlanPieChartWidg
(AppLocalizations.of(context).carbohydrates, LIST_OF_COLORS3[0]),
(AppLocalizations.of(context).fat, LIST_OF_COLORS3[2]),
]
.map((e) => Padding(
padding: const EdgeInsets.symmetric(vertical: 2),
child: Indicator(color: e.$2, text: e.$1, isSquare: true),
))
.toList(),
.map((e) => Padding(
padding: const EdgeInsets.symmetric(vertical: 2),
child: Indicator(color: e.$2, text: e.$1, isSquare: true),
))
.toList(),
),
const SizedBox(width: 28),
],
@@ -441,15 +441,15 @@ class NutritionalDiaryChartWidgetFlState extends State<NutritionalDiaryChartWidg
(AppLocalizations.of(context).today, colorLoggedToday),
(AppLocalizations.of(context).weekAverage, colorLogged7Day),
]
.map(
(e) => Indicator(
color: e.$2,
text: e.$1,
isSquare: true,
marginRight: 0,
),
)
.toList(),
.map(
(e) => Indicator(
color: e.$2,
text: e.$1,
isSquare: true,
marginRight: 0,
),
)
.toList(),
),
),
],

View File

@@ -66,7 +66,7 @@ class NutritionalPlansList extends StatelessWidget {
return AlertDialog(
content: Text(
AppLocalizations.of(context)
.confirmDelete(currentPlan.description),
.confirmDelete(currentPlan.description),
),
actions: [
TextButton(

View File

@@ -40,9 +40,7 @@ class WeightEntriesList extends StatelessWidget {
padding: const EdgeInsets.all(15),
height: 220,
child: MeasurementChartWidgetFl(
weightProvider.items
.map((e) => MeasurementChartEntry(e.weight, e.date))
.toList(),
weightProvider.items.map((e) => MeasurementChartEntry(e.weight, e.date)).toList(),
unit: profile!.isMetric
? AppLocalizations.of(context).kg
: AppLocalizations.of(context).lb,

View File

@@ -82,9 +82,7 @@ class SettingWidget extends StatelessWidget {
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
...set
.getSmartRepr(setting.exerciseObj)
.map((e) => Text(e)),
...set.getSmartRepr(setting.exerciseObj).map((e) => Text(e)),
],
),
);