Skip to content

Conversation

@pr4s4di
Copy link

@pr4s4di pr4s4di commented Nov 25, 2023

Background

First of all, thank you for your work.
I am currently working on a fitness app, and I'm using your library to allow users to insert their weight. I have a function that enables users to update their weight, so I need to start the weight picker at the latest user's weight when a user wants to update their weight.
I am adding a new initialValue parameter that indicates the initial point of the weight picker.

Steps

  1. Add initialValue parameter.
  2. Add FixedExtendScrollController so i can jump to any index in the list view.
  3. Add PostFrameCallback function in initState to jump to initialValue when the view is finished built

@redwildrider
Copy link

Hi,
I like your solution @prasetya4di.
But you can also solve it without the PostFrameCallback:
The scroll controller can be configured with an initial value.

@pr4s4di
Copy link
Author

pr4s4di commented Jan 23, 2024

Hi @redwildrider, thank you for your advice, i forgot to read the documentation.
I'll update the PR asap 👍

…use initial item in FixedExtentScrollController instead
@pr4s4di
Copy link
Author

pr4s4di commented Jan 23, 2024

Done @redwildrider, please kindly review it again 😄

@jesusmarzor
Copy link

jesusmarzor commented Mar 16, 2024

I like your solution @prasetya4di .

I'm looking forward to seeing the new version with your changes!!

Thanks 😄

@bparol
Copy link

bparol commented May 24, 2024

I like your solution @prasetya4di .

I'm looking forward to seeing the new version with your changes!!

Thanks 😄

Any chance it will go live soon?

@pr4s4di
Copy link
Author

pr4s4di commented May 27, 2024

I like your solution @prasetya4di .
I'm looking forward to seeing the new version with your changes!!
Thanks 😄

Any chance it will go live soon?

Hello @redwildrider is there any plan to release a new version ? 😁

@bparol
Copy link

bparol commented May 30, 2024

@prasetya4di I think there is a bug in your solution in place where initialValue is set as _selectedIndex:

538: _selectedIndex = ((widget.initialValue ?? 0) / interval).round();

but here you take _selectedIndex as index for list that actually has (max - min) / division elements

705:  _valueList[_selectedIndex].value,

i.e. if you set min = 20, max = 100 and division = 1, then _valueList has 80 elements, but you can set initialValue to 90, which is in range, and that will crash. Current solution works only if min is set to 0, but then another assert will fire.

Thanks for your work!

@pr4s4di
Copy link
Author

pr4s4di commented Aug 4, 2024

@prasetya4di I think there is a bug in your solution in place where initialValue is set as _selectedIndex:

538: _selectedIndex = ((widget.initialValue ?? 0) / interval).round();

but here you take _selectedIndex as index for list that actually has (max - min) / division elements

705:  _valueList[_selectedIndex].value,

i.e. if you set min = 20, max = 100 and division = 1, then _valueList has 80 elements, but you can set initialValue to 90, which is in range, and that will crash. Current solution works only if min is set to 0, but then another assert will fire.

Thanks for your work!

Sorry it took me a while to update the code, been busy with work. By the way thanks for the insight, i'm update the code so it able to support your use case 😄

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.

4 participants