Closed julientechdev closed 3 years ago
I agree this is a needed change for all the list type pickers. It's a breaking change so will need to go into the 2.0 version.
Hello there, thanks for the hard work! Do you plan to add this feature in a future release ? If I want to show localized String, conversion back and forth can become tricky without a fixed value being exchanged.
What if I add an optional "values" collection? That way it won't be a breaking change.
Yes that could be a good solution.
Although to do not break it I think it should still be a String list, and if a value List is provided, the variable returned as picked value, is the String from the value array instead of the String from the items array.
For example using enum, this could be straightforward. You would pass the localized version of the enum to the item list, and the enum label to the value list.
A breaking change could have two values returned, both the value and item and hence having the value be any type (i.e the enum value itself).
Another possibility could be a new type of picker altogether because you do not need this when using a numeric, date or color picker. You only need this when using String or Icon + String in my opinion... Although that may not be true for everyone.
Feature added to 2.1.0
@codegrue: Isn't the whole point of the values/items separation that the user never sees the values, but only the items (labels)?
Unfortunately now it shows the values instead of the items if provided. It should instead show the items and use the values as selectedValue
.
No it shows the items in the pickers. The sample app is displaying the returned values, but that's outside the library.
To show the item outside the picker, you would have to find the index of the value in the values list then get the item from the items list at the same index.
But it doesn't show the items in the picker?
In your example MaterialScrollPicker shows the State Abbreviations in the Picker as well which is the list of values, not items, and it's the same in my application.
The Text widget for each item uses the value variable, which is called from values. The items are not shown anywhere, unless we're both totally missing something?
No it shows the items in the pickers.
It doesn't.
To elaborate: Completely agree with your statement @codegrue. Only problem is that it does not behave as you described. (The PR linked above fixes the issue).
Can you post some screen shots? For me the example app behaves as I describe.
Hold on, checking...
Fixed in 2.1.1. Sorry this was a lack of regression testing bug. Thanks for raising it and for the PR.
Thx @codegrue
Thanks for the super quick fix!
Yes thank you,
That works great.
On Tue, Apr 13, 2021, 11:15 elliotrtd @.***> wrote:
Thanks for the super quick fix!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/codegrue/flutter_material_pickers/issues/15#issuecomment-818816884, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADK6WKTLMCWBF6O7265KPJDTIRNYVANCNFSM4SH2NV2Q .
The scrollpicker is currently taking a list of Strings as items parameter.
I have a use case where I'd like to pass a list of objects as items and specify which object property to use as label (showing in the list), but when selected the returning value would be another object property.
Here's what the show function call might look like: