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

reactive_touch_spin doesn't display programmatic value updates #37

Closed
BenjiFarquhar opened this issue Jan 31, 2022 · 16 comments
Closed

Comments

@BenjiFarquhar
Copy link

reactive_touch_spin only displays updated values from clicking the up and down arrows to change the number, not from resetting the form values or calling updateValue() or any of the other numerous ways of changing the value programmatically using reactive_forms.

@BenjiFarquhar
Copy link
Author

To recreate - edit the example app - example/lib/main.dart and make the sign up button update the value:

ElevatedButton(
  child: const Text('Sign Up'),
  onPressed: () {
    if (form.valid) {
      // ignore: avoid_print
      form.control('touchSpin').updateValue(50);
      print(form.value);
    } else {
      form.markAllAsTouched();
    }
  },
),

@BenjiFarquhar
Copy link
Author

BenjiFarquhar commented Jan 31, 2022

I don't think you'll be able to use flutter_touch_spin due to this issue.

It kind of makes the widget, not a reactive_forms widget as it is unresponsive to reactive_forms.

@vasilich6107
Copy link
Contributor

Hi @BenjaminFarquhar
Thanks for investigating.

It seems that I will need to make PR one more time and release a temp substitution for the control)
After making PR i will ask you to tag the maintainer for releasing an update.

@BenjiFarquhar
Copy link
Author

BenjiFarquhar commented Jan 31, 2022

@vasilich6107 You're welcome! Sounds good! Sure, will do.

@vasilich6107
Copy link
Contributor

@BenjaminFarquhar done
Let's tag the maintainer)

@vasilich6107
Copy link
Contributor

danvick/flutter_touch_spin#14

@vasilich6107
Copy link
Contributor

@BenjaminFarquhar check latest version

@BenjiFarquhar
Copy link
Author

@vasilich6107 I will do thank you. I have confirmed it is working. Thanks for the quick fix.

@BenjiFarquhar
Copy link
Author

@vasilich6107 in version 0.4.0 I get the error:

setState() or markNeedsBuild() called during build.

When I go back to ^0.3.0-nullsafety.2 I don't get the error. I don't have time right now to investigate so I'm staying on ^0.3.0-nullsafety.2 as everything is working fine for me on that - changing the value from the outside is also working in that version.

@vasilich6107
Copy link
Contributor

Could you provide reproduction code?

@BenjiFarquhar
Copy link
Author

BenjiFarquhar commented Feb 7, 2022

@vasilich6107 The bug occurs when you run the example project and click on the + or - in the widget with the mouse

@vasilich6107
Copy link
Contributor

@BenjaminFarquhar
here is my PR updates
image

here is what inside
image

@vasilich6107
Copy link
Contributor

I do not know why author added setState call

@vasilich6107
Copy link
Contributor

vasilich6107 commented Feb 7, 2022

@BenjaminFarquhar

From flutter docs

The framework always calls [build](https://api.flutter.dev/flutter/widgets/State/build.html) after 
calling [didUpdateWidget](https://api.flutter.dev/flutter/widgets/State/didUpdateWidget.html), 
which means any calls to [setState](https://api.flutter.dev/flutter/widgets/State/setState.html) in [didUpdateWidget]
(https://api.flutter.dev/flutter/widgets/State/didUpdateWidget.html) are redundant.```

@vasilich6107
Copy link
Contributor

vasilich6107 commented Feb 7, 2022

@BenjaminFarquhar check latest version
reactive_touch_spin: ^0.4.1

@BenjiFarquhar
Copy link
Author

Cool, thanks @vasilich6107

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

No branches or pull requests

2 participants