textEditingControllerObserve<ObservedState, S, A> static method

WithStore<ObservedState, A> textEditingControllerObserve<ObservedState, S, A>({
  1. required Store<S, A> store,
  2. required ObservedState observe(
    1. S observedState
    ),
  3. required String toText(
    1. S state
    ),
  4. required A fromTextEditingAction(
    1. TextEditingAction action
    ),
  5. required TextEditingControllerWithStoreBuilder<ObservedState, A> builder,
  6. bool isEqual(
    1. ObservedState previous,
    2. ObservedState current
    ) = IsEqualUtils.stateAreEquals,
  7. Key? key,
})

Combines state observation with a TextEditingController binding.

Projects state via observe for selective rebuilds while maintaining two-way text synchronization.

Implementation

static WithStore<ObservedState, A> textEditingControllerObserve<ObservedState, S, A>({
  required Store<S, A> store,
  required ObservedState Function(S observedState) observe,
  required String Function(S state) toText,
  required A Function(TextEditingAction action) fromTextEditingAction,
  required TextEditingControllerWithStoreBuilder<ObservedState, A> builder,
  bool Function(ObservedState previous, ObservedState current) isEqual = IsEqualUtils.stateAreEquals,
  Key? key,
}) =>
    WithStore<ObservedState, A>(
      store: store.scope(toLocalState: observe, toGlobalAction: (action) => action),
      builder: (state, send, context) => TextEditingControllerBuilder<S, A>(
        key: key,
        builder: (controller, focusNode) => builder(
          state,
          send,
          context,
          controller,
          focusNode,
        ),
        store: store,
        toText: toText,
        fromTextEditingAction: fromTextEditingAction,
      ),
      isEqual: isEqual,
    );