CodeInput constructor

CodeInput({
  1. Key? key,
  2. required int length,
  3. FocusNode? focusNode,
  4. TextInputType keyboardType = TextInputType.text,
  5. List<TextInputFormatter>? inputFormatters,
  6. required CodeInputBuilder builder,
  7. double spacing = 8,
  8. void onChanged(
    1. String value
    )?,
  9. void onFilled(
    1. String value
    )?,
  10. void onDone(
    1. String value
    )?,
})

Implementation

factory CodeInput({
  Key? key,
  required int length,
  FocusNode? focusNode,
  TextInputType keyboardType = TextInputType.text,
  List<TextInputFormatter>? inputFormatters,
  required CodeInputBuilder builder,
  double spacing = 8,
  void Function(String value)? onChanged,
  void Function(String value)? onFilled,
  void Function(String value)? onDone,
}) {
  assert(length > 0, 'The length needs to be larger than zero.');
  assert(length.isFinite, 'The length needs to be finite.');

  return CodeInput._(
    key: key,
    length: length,
    focusNode: focusNode ?? FocusNode(),
    keyboardType: keyboardType,
    inputFormatters:
        inputFormatters ?? _createInputFormatters(length, keyboardType),
    builder: builder,
    spacing: spacing,
    onChanged: onChanged,
    onFilled: onFilled,
    onDone: onDone,
  );
}