TTextField<T extends String?>.scan constructor

TTextField<T extends String?>.scan({
  1. Key? key,
  2. T? value,
  3. String? label,
  4. String? placeholder = 'Scan or type',
  5. required ValueChanged<String> onScan,
  6. VoidCallback? onCameraTap,
  7. TInputSize? size,
  8. bool autoFocus = true,
  9. bool disabled = false,
  10. bool readOnly = false,
  11. String? helperText,
  12. FocusNode? focusNode,
  13. TextEditingController? textController,
})

Creates a scan-first input for handheld workflows.

A hardware (keyboard-wedge) scanner types the barcode and sends Enter; that fires onScan with the scanned text, clears the field and keeps focus ready for the next scan. onCameraTap adds a camera scan button.

Implementation

factory TTextField.scan({
  Key? key,
  T? value,
  String? label,
  String? placeholder = 'Scan or type',
  required ValueChanged<String> onScan,
  VoidCallback? onCameraTap,
  TInputSize? size,
  bool autoFocus = true,
  bool disabled = false,
  bool readOnly = false,
  String? helperText,
  FocusNode? focusNode,
  TextEditingController? textController,
}) {
  return TTextField<T>(
    key: key,
    value: value,
    label: label,
    placeholder: placeholder,
    helperText: helperText,
    size: size,
    autoFocus: autoFocus,
    disabled: disabled,
    readOnly: readOnly,
    focusNode: focusNode,
    textController: textController,
    textInputAction: TextInputAction.done,
    selectAllOnFocus: true,
    clearOnSubmit: true,
    keepFocusOnSubmit: true,
    postWidget: onCameraTap == null
        ? null
        : IconButton(
            tooltip: 'Scan with camera',
            constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
            icon: TIcon.raw(HugeIcons.strokeRoundedScan),
            onPressed: disabled ? null : onCameraTap,
          ),
    onSubmitted: (text) {
      final trimmed = text.trim();
      if (trimmed.isNotEmpty) onScan(trimmed);
    },
  );
}