Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #165: add Key parameter to makePicker #166

Conversation

kainosk
Copy link

@kainosk kainosk commented Feb 14, 2022

This will fix #165.

I added key parameter to makePicker method. If I pass consistent key to makePicker, the picker's dragging behavior is not interrupted (this is my expected behavior.)

If I call makePicker on build method, every build use different key ('ValueKey(this)') for PickerWidget and this interrupt dragging (scrolling). With this PR, we can assign key for PickerWidget explicitly or we can omit key for using conventional key ('ValueKey(this)').

👇 is sample code to use this parameter.

final picker = Picker(...);
return picker.makePicker(Theme.of(context), false, ValueKey('MyKey'));

If #165 is not correct usage, please close this PR 😢 Thank you ❤️

@@ -215,7 +215,8 @@ class Picker {
actions.add(TextButton(
style: _getButtonStyle(ButtonTheme.of(context)),
onPressed: () async {
if (onConfirmBefore != null && !(await onConfirmBefore!(this, selecteds))) {
if (onConfirmBefore != null &&
!(await onConfirmBefore!(this, selecteds))) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just dart formatter's fix.

daySuffix,
hourSuffix,
minuteSuffix,
secondSuffix;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just dart formatter's fix.

@@ -1215,7 +1221,7 @@ class DateTimePickerAdapter extends PickerAdapter<DateTime> {
if (!_needUpdatePrev) {
// check am/pm before hour-ap
var ap = _columnType.indexWhere((element) => element == 6);
if (ap > _columnType.indexWhere((element) => element == 7)) {
if (ap > _columnType.indexWhere((element) => element == 7)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just dart formatter's fix.

@@ -1432,7 +1438,8 @@ class DateTimePickerAdapter extends PickerAdapter<DateTime> {
if (minuteInterval == null || minuteInterval! < 2)
_text = "${intToStr(index)}${_checkStr(minuteSuffix)}";
else
_text = "${intToStr(index * minuteInterval!)}${_checkStr(minuteSuffix)}";
_text =
"${intToStr(index * minuteInterval!)}${_checkStr(minuteSuffix)}";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just dart formatter's fix.

@yangyxd
Copy link
Owner

yangyxd commented Feb 21, 2022

Thanks!

@yangyxd yangyxd closed this Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dragging is interrupted when call setState on onSelect
2 participants