updateFromExternal method

void updateFromExternal(
  1. String value
)

Pushes an external string value into the PIN cells. Designed for custom keyboard widgets that control the field externally.

Implementation

void updateFromExternal(String value) {
  if (_isDisposed) return;

  final capped = value.length > length ? value.substring(0, length) : value;

  for (int i = 0; i < length; i++) {
    if (i < controllers.length) {
      controllers[i].text = i < capped.length ? capped[i] : '';
    }
  }

  if (capped.length == length) {
    _submit();
  }
}