diff --git a/lib/widgets/dashboard/widgets.dart b/lib/widgets/dashboard/widgets.dart index aedf5ef6..e80465d4 100644 --- a/lib/widgets/dashboard/widgets.dart +++ b/lib/widgets/dashboard/widgets.dart @@ -243,12 +243,10 @@ class DashboardWeightWidget extends StatefulWidget { } class _DashboardWeightWidgetState extends State { - late BodyWeightProvider weightEntriesData; - @override Widget build(BuildContext context) { final profile = context.read().profile; - weightEntriesData = Provider.of(context, listen: false); + final weightProvider = context.read(); return Consumer( builder: (context, workoutProvider, child) => Card( @@ -267,13 +265,13 @@ class _DashboardWeightWidgetState extends State { ), Column( children: [ - if (weightEntriesData.items.isNotEmpty) + if (weightProvider.items.isNotEmpty) Column( children: [ SizedBox( height: 200, child: MeasurementChartWidgetFl( - weightEntriesData.items + weightProvider.items .map((e) => MeasurementChartEntry(e.weight, e.date)) .toList(), unit: profile!.isMetric @@ -296,7 +294,7 @@ class _DashboardWeightWidgetState extends State { FormScreen.routeName, arguments: FormScreenArguments( AppLocalizations.of(context).newEntry, - WeightForm(), + WeightForm(weightProvider.getNewestEntry()?.copyWith(id: null)), ), ); },