shaderone
shaderone

Reputation: 498

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

Upvotes: 0

Views: 912

Answers (1)

Peter Koltai
Peter Koltai

Reputation: 9734

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.

Upvotes: 3

Related Questions