flutter_picker icon indicating copy to clipboard operation
flutter_picker copied to clipboard

Making data model for independent value groups

Open Skquark opened this issue 7 years ago • 5 comments

I am trying to figure out how to make the data array of PickerItems (or a Json) that isn't linked with it's children, and can't find the right method. I'm wanting to use this for a Height Picker with Feet & Inches, and a Weight Picker with Pounds & Ounces, but I don't want the the two sides of the data fields linked with each other. So on one side would be values of 0 ' - 7 ' then 0 " - 11 " and for the weight I want lbs and oz with a range. It would have been nice to set a picker with a min int and max int, but I could live with putting the text and values by hand. Is there a way to code this the way it is, or is this a feature request?

I was also looking for a way to set the initial saved data value, so when I go back to edit a picker, it starts with the current values. I studied the docs and examples and couldn't find the answers. Thanks.

Skquark avatar Sep 07 '18 13:09 Skquark

There is a lack of such adapters.I will take time to add it.If you use it urgently, you can refer to DateTime Picker Adapter to implement one.

yangyxd avatar Sep 10 '18 05:09 yangyxd

I temporarily worked around the problem by having a really big dataset for each number, with a lot of copy & pasting to get the desired picker. However, I just got your new update with your Number Picker Adapter, and much happier with it, thanks very much.. One feature request I have that would make it more usable for picking measurements is to add a suffix (might as well add prefix too for currency symbol and stuff) optional field to the NumberPickerColumn so the text would display like 8 lbs | 3 oz, or 5' | 4" or whatever. The value would be just the number, but without the suffix they wouldn't know what they're picking. I picture adding it like this: adapter: NumberPickerAdapter(data: [ NumberPickerColumn(begin: 0, end: 600, suffix: " lbs"), NumberPickerColumn(begin: 0, end: 15, suffix: " oz")]), Hope I'm not asking for too much, but it would make sense to have the capability to make it more multi-purposed for everyone, and I don't think the code would be too difficult. Thanks, looking good..

Skquark avatar Sep 14 '18 10:09 Skquark

Your suggestion is very good. I will improve it.

yangyxd avatar Sep 15 '18 06:09 yangyxd

Excellent, now there's a lot more potential uses for this picker.. Thanks.

Ran into a slight problem, when I tried to run the new version, I was getting this Unhandled exception: E/flutter (11369): NoSuchMethodError: The getter 'cancelText' was called on null. E/flutter (11369): Receiver: null E/flutter (11369): Tried calling: cancelText E/flutter (11369): Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5) E/flutter (11369): Picker.showDialog (package:flutter_picker/Picker.dart:153:55)

I had to add a cancelText and confirmText string for it to work, problem when it's default, probably has something to do with the PickerLocalizations..

Skquark avatar Sep 19 '18 12:09 Skquark

Thank you. This problem has been fixed.

yangyxd avatar Sep 20 '18 10:09 yangyxd