Fingertips18 / scroll-wheel-date-picker

A Flutter package for a scrollable and flat perspective wheel-type date picker like in TikTok.
https://pub.dev/packages/scroll_wheel_date_picker
MIT License
4 stars 6 forks source link

Removed default text color, fixed DateController initialization #3

Closed LeonManolo closed 5 months ago

LeonManolo commented 6 months ago

When setState is called within a parent widget of the ScrollWheelDatePicker widget, the DateController is reinitialized, leading to the override of the current DateTime and an unsynced UI. This issue arises, for instance, when setState is invoked inside the onSelectedItemChanged callback. Consequently, the widget undergoes partial rebuilding, triggering a new initialization of the DateController.

/// initialDate = 1.1.1990
/// For example, if the date is initially set to 1.1.1990 and the year is increased by one, the resulting date should be 1.1.1991.
onSelectedItemChanged: (date) {
    setState(() {
        _myDateVariable = date;
    });
    print(date);
},

/// However, if we subsequently change the day (or month in this case) by incrementing it by one, the date becomes 1.2.1990 instead of 1.2.1991.

Additional Changes:

Removed the default text color to allow the utilization of the default color from the app theme.

Fingertips18 commented 5 months ago

@LeonManolo This commit 82a410790c89667a84189996ef7c92eff36dd734 solved the issue.