async method

ValueListenable<T> async()

ValueListenable are inherently synchronous. In most cases this is what you want. But if for example your ValueListenable gets updated inside a build method of a widget which would trigger a rebuild because your widgets is listening to the ValueListenable you get an exception that you called setState inside a build method. By using async you push the update of the ValueListenable to the next frame. This way you can update the ValueListenable inside a build method without getting an exception.

Implementation

ValueListenable<T> async() {
  return AsyncValueNotifier(
    this.value,
    this,
  );
}