registerOnChange method

  1. @override
void registerOnChange(
  1. ChangeFunction<T> callback
)

Set the function to be called when the control receives a change event.

NOTE: This function should only be called by view (i.e. user-initiated) changes. Incorrect implementation of registerOnChange will cause issues such as the control incorrectly being marked as dirty from a model update.

Implementation

@override
void registerOnChange(callback) {
  disposer.addStreamSubscription(_updateStream.listen((_) {
    //if (input == null) return; // Input is no longer valid
    final rawValue = input.inputText;
    final value = parseNumber(rawValue);
    // Pass the rawValue and the num value. This allows validators to process
    // whichever one they would like.
    callback(value, rawValue: rawValue);
  }));
}