acceptProviders abstract method

void acceptProviders(
  1. Accept accept
)

Preparation for accepting Value provided by Provider. An object returned by watch is a target to observe changes. accept is called when the object returned by watch changes.

{@tool snippet}

In this example, _MultipleCounterState observs the change of value of CounterState, which extends ValueNotifier and provided by ChangeNotifierProvider. When value is changed, appyl is called with value as an argument. value is set to _value with being mutiplied, and used in build method.

class _MultipleCounterState
   extends AcceptableStatefulWidgetState<MultipleCounter> {
 late int _value;

  @override
  void acceptProviders(Accept accept) {
    accept<CounterState, int>(
      watch: (state) => state.value,
      apply: (value) => _value = value * 2,
    );
  }
}

{@end-tool}

accept can be called multiple times if observing multiple objects is necessary.

Implementation

void acceptProviders(Accept accept);