Abhilash-Chandran / number_inc_dec

A flutter widget to accept numeric inputs with button to increment and decrement.
https://pub.dev/packages/number_inc_dec
MIT License
10 stars 7 forks source link

How to disable editing number but only using inc/dec buttons #38

Closed maxrks closed 3 years ago

maxrks commented 3 years ago

I tried to set the 'disabled' in true, but got the controls away from inputting both in editing and pressing. Could there be an option to disable the inputting but only enable pressing inc/dec buttons? Thanks!

Abhilash-Chandran commented 3 years ago

Hi @maxrks , Thanks for raising an issue. In its current form enabled = false attribute should only disable editing and keep the inc/dec buttons enabled. Could you share your code so I can verify your use case.

maxrks commented 3 years ago

Hi @maxrks , Thanks for raising an issue. In its current form enabled = false attribute should only disable editing and keep the inc/dec buttons enabled. Could you share your code so I can verify your use case.

Thanks for replying quickly!

I've set up testing repo flutter_number_inc_dec_test for your checking.

If the enabledset to be false, both the box-buttons and the input area were disabled.

Another issue found when testing made, the buttons boxs might overflow in the singlescrollview, could you fix it?

test_2021-05-05_09-44-13
Abhilash-Chandran commented 3 years ago

Thanks for replying quickly!

I've set up testing repo flutter_number_inc_dec_test for your checking.

If the enabledset to be false, both the box-buttons and the input area were disabled.

Another issue found when testing made, the buttons boxs might overflow in the singlescrollview, could you fix it?

test_2021-05-05_09-44-13

Thank you once again for your efforts for the code to reproduce the bug.

I will look into this issue for sure. I am currently busy with my master thesis until end of this month, so I can't promise a fix soon. If the issue is not big I will make a patch release if possible this weekend.

Regarding the overflow of the widget in scrollable could you check if its similar to this issue #33 .? This is bug in flutter itself where inkwell paints beyond the boundaries of the scrollable widget and I have already raised a bug in flutter for it https://github.com/flutter/flutter/issues/73315.

Abhilash-Chandran commented 3 years ago

I just verified the code and I can see I have disabled the increment and decrement button when enabled is set to false. So it is working as designed. But you requirement is valid and hence I will need to add a separate field for disabling the manual editing of the field. Sorry for the inconvenience. I will see what I can do for this. I actually made quite a lot of changes with more validations and planned a release 0.7.5 but I couldn't keep it up with my current schedule. For time being I would suggest you could copy the single file I have in the package into your local project and remove the check I have done here https://github.com/Abhilash-Chandran/number_inc_dec/blob/39aba4ad35033b81f13622c2386e2e047e641fc4/lib/src/number_increment_decrement.dart#L798 and here https://github.com/Abhilash-Chandran/number_inc_dec/blob/39aba4ad35033b81f13622c2386e2e047e641fc4/lib/src/number_increment_decrement.dart#L798.

This way you will have what you want for time being and I can release a better version including null safety some time in June.

Abhilash-Chandran commented 3 years ago

In retrospect it might not be that simple either. Because when disabled, then you will still want the text to be visible with the number. I think this might take some time, unfortunately... I think you will have to expose the readonly property from textformfield and then use it.

maxrks commented 3 years ago

Appreciating for your kindness! The topic is not urgent, I'd like check up progress few weeks later, but the career is more important, and wishes your success and good luck!

maxrks commented 3 years ago

I've tested that the issue has been solved, thanks!