Home > other >  Flutter : Update text using Valuenotifier
Flutter : Update text using Valuenotifier

Time:11-29

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

CodePudding user response:

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.

  • Related