solve the date fix in a cleaner way

This commit is contained in:
Dieter Plaetinck
2024-09-07 19:44:50 +03:00
parent eaef5513b9
commit 14bd370503
3 changed files with 5 additions and 3 deletions

View File

@@ -43,7 +43,7 @@ class WeightEntry {
WeightEntry copyWith({int? id, int? weight, DateTime? date}) => WeightEntry(
id: id,
weight: weight ?? this.weight,
date: date ?? DateTime.now(),
date: date ?? this.date,
);
// Boilerplate

View File

@@ -43,7 +43,7 @@ class WeightScreen extends StatelessWidget {
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).newEntry,
WeightForm(lastWeightEntry?.copyWith(id: null)),
WeightForm(lastWeightEntry?.copyWith(id: null, date: DateTime.now())),
),
);
},

View File

@@ -209,7 +209,9 @@ 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, date: DateTime.now())),
),
);
},