Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter : Update text using Valuenotifier

I am using valuenotifier to update a text as an alternative to having a stateful widget and calling setstate. I was able to get the selected value from the dropdownFormFieldbut could not display it.

https://dartpad.dev/?id=62d831a1b6ff472e080d5b18f9bae2ef&null_safety=true

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Simply add this to the onChanged method:

_text.value = value.toString();

This will update the value of your ValueNotifier and the ValueListenableBuilder will catch it and rebuild.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading