Skip to content

Commit 14bd370

Browse files
committed
solve the date fix in a cleaner way
1 parent eaef551 commit 14bd370

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

lib/models/body_weight/weight_entry.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class WeightEntry {
4343
WeightEntry copyWith({int? id, int? weight, DateTime? date}) => WeightEntry(
4444
id: id,
4545
weight: weight ?? this.weight,
46-
date: date ?? DateTime.now(),
46+
date: date ?? this.date,
4747
);
4848

4949
// Boilerplate

lib/screens/weight_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class WeightScreen extends StatelessWidget {
4343
FormScreen.routeName,
4444
arguments: FormScreenArguments(
4545
AppLocalizations.of(context).newEntry,
46-
WeightForm(lastWeightEntry?.copyWith(id: null)),
46+
WeightForm(lastWeightEntry?.copyWith(id: null, date: DateTime.now())),
4747
),
4848
);
4949
},

lib/widgets/dashboard/widgets.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ class _DashboardWeightWidgetState extends State<DashboardWeightWidget> {
209209
FormScreen.routeName,
210210
arguments: FormScreenArguments(
211211
AppLocalizations.of(context).newEntry,
212-
WeightForm(weightProvider.getNewestEntry()?.copyWith(id: null)),
212+
WeightForm(weightProvider
213+
.getNewestEntry()
214+
?.copyWith(id: null, date: DateTime.now())),
213215
),
214216
);
215217
},

0 commit comments

Comments
 (0)