consume method

Widget consume(
  1. Widget create(), {
  2. Key? key,
})

Create a consumer widget and connect with the watched variable. The consumer widget will rebuild whenever the watched variable updates.

e.g.

watchedVar.consume(() => widget)

is to touch() the watched variable itself first and then globalConsume(() => widget).

Implementation

Widget consume(Widget Function() create, {Key? key}) {
  wrapFn() {
    touch();
    return create();
  }

  return globalConsume(wrapFn, key: key);
}