flutter icon indicating copy to clipboard operation
flutter copied to clipboard

bug with datepicker for weight measurements

Open Dieterbe opened this issue 5 months ago • 0 comments

i have logged a weight entry today at 20:57:13 when i go to the "new entry" dialog, and tap on the calendar - so i can choose a new day (e.g. to log yesterday's weight) - it triggers this exception:

E/flutter (19174): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/material/date_picker.dart': Failed assertion: line 205 pos 5: 'selectableDayPredicate == null || initialDate == null || selectableDayPredicate(initialDate)': Provided initialDate 2024-09-18 00:00:00.000 must satisfy provided selectableDayPredicate.

why? because it uses selectableDayPredicate to only allow certain dates. while it does this:

                  // Always allow the current initial date
                  if (day == _weightEntry.date) {
                    return true;
                  }

this doesn't actually work because day is 2024-09-18 00:00:00.000 and _weightEntry.date is 2024-09-18 20:57:13.511178

since https://github.com/wger-project/flutter/pull/633, we started logging values with non-0 hours/minutes/seconds

this brings up the question: should we allow logging multiple values within the same day (e.g. keep the hour-minute-second precision)? while probably not typically useful, i don't see much harm in it either. or are there other places (e.g. calendar) where we make assumptions of "max once per day" ?

Dieterbe avatar Sep 18 '24 18:09 Dieterbe