TextBox constructor

const TextBox({
  1. Key? key,
  2. TextEditingController? controller,
  3. FocusNode? focusNode,
  4. BoxDecoration decoration = _kDefaultRoundedBorderDecoration,
  5. EdgeInsetsGeometry padding = kTextBoxPadding,
  6. String? placeholder,
  7. TextStyle? placeholderStyle,
  8. Widget? prefix,
  9. Widget? outsidePrefix,
  10. OverlayVisibilityMode prefixMode = OverlayVisibilityMode.always,
  11. OverlayVisibilityMode outsidePrefixMode = OverlayVisibilityMode.always,
  12. Widget? suffix,
  13. Widget? outsideSuffix,
  14. OverlayVisibilityMode suffixMode = OverlayVisibilityMode.always,
  15. OverlayVisibilityMode outsideSuffixMode = OverlayVisibilityMode.always,
  16. TextInputType? keyboardType,
  17. TextInputAction? textInputAction,
  18. TextStyle? style,
  19. StrutStyle? strutStyle,
  20. TextAlign textAlign = TextAlign.start,
  21. TextAlignVertical? textAlignVertical,
  22. bool readOnly = false,
  23. ToolbarOptions? toolbarOptions,
  24. bool? showCursor,
  25. bool autofocus = false,
  26. String obscuringCharacter = '•',
  27. bool obscureText = false,
  28. bool autocorrect = true,
  29. SmartDashesType? smartDashesType,
  30. SmartQuotesType? smartQuotesType,
  31. bool enableSuggestions = true,
  32. int? maxLines = 1,
  33. int? minLines,
  34. double? minHeight,
  35. bool expands = false,
  36. int? maxLength,
  37. bool maxLengthEnforced = true,
  38. ValueChanged<String>? onChanged,
  39. VoidCallback? onEditingComplete,
  40. ValueChanged<String>? onSubmitted,
  41. List<TextInputFormatter>? inputFormatters,
  42. bool? enabled,
  43. double cursorWidth = 1.5,
  44. double? cursorHeight,
  45. Radius cursorRadius = const Radius.circular(2.0),
  46. Color? cursorColor,
  47. BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
  48. BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
  49. Brightness? keyboardAppearance,
  50. EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  51. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  52. bool enableInteractiveSelection = true,
  53. GestureTapCallback? onTap,
  54. ScrollController? scrollController,
  55. ScrollPhysics? scrollPhysics,
  56. Iterable<String>? autofillHints,
  57. String? restorationId,
  58. TextCapitalization textCapitalization = TextCapitalization.none,
  59. String? header,
  60. TextStyle? headerStyle,
  61. ButtonThemeData? iconButtonThemeData,
})

Implementation

const TextBox({
  Key? key,
  this.controller,
  this.focusNode,
  this.decoration = _kDefaultRoundedBorderDecoration,
  this.padding = kTextBoxPadding,
  this.placeholder,
  this.placeholderStyle,
  this.prefix,
  this.outsidePrefix,
  this.prefixMode = OverlayVisibilityMode.always,
  this.outsidePrefixMode = OverlayVisibilityMode.always,
  this.suffix,
  this.outsideSuffix,
  this.suffixMode = OverlayVisibilityMode.always,
  this.outsideSuffixMode = OverlayVisibilityMode.always,
  TextInputType? keyboardType,
  this.textInputAction,
  this.style,
  this.strutStyle,
  this.textAlign = TextAlign.start,
  this.textAlignVertical,
  this.readOnly = false,
  ToolbarOptions? toolbarOptions,
  this.showCursor,
  this.autofocus = false,
  this.obscuringCharacter = '•',
  this.obscureText = false,
  this.autocorrect = true,
  SmartDashesType? smartDashesType,
  SmartQuotesType? smartQuotesType,
  this.enableSuggestions = true,
  this.maxLines = 1,
  this.minLines,
  this.minHeight,
  this.expands = false,
  this.maxLength,
  this.maxLengthEnforced = true,
  this.onChanged,
  this.onEditingComplete,
  this.onSubmitted,
  this.inputFormatters,
  this.enabled,
  this.cursorWidth = 1.5,
  this.cursorHeight /* = 28 */,
  this.cursorRadius = const Radius.circular(2.0),
  this.cursorColor,
  this.selectionHeightStyle = ui.BoxHeightStyle.tight,
  this.selectionWidthStyle = ui.BoxWidthStyle.tight,
  this.keyboardAppearance,
  this.scrollPadding = const EdgeInsets.all(20.0),
  this.dragStartBehavior = DragStartBehavior.start,
  this.enableInteractiveSelection = true,
  this.onTap,
  this.scrollController,
  this.scrollPhysics,
  this.autofillHints,
  this.restorationId,
  this.textCapitalization = TextCapitalization.none,
  this.header,
  this.headerStyle,
  this.iconButtonThemeData,
})  : assert(obscuringCharacter.length == 1),
      smartDashesType = smartDashesType ??
          (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
      smartQuotesType = smartQuotesType ??
          (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
      assert(maxLines == null || maxLines > 0),
      assert(minLines == null || minLines > 0),
      assert(
        (maxLines == null) || (minLines == null) || (maxLines >= minLines),
        "minLines can't be greater than maxLines",
      ),
      assert(
        !expands || (maxLines == null && minLines == null),
        'minLines and maxLines must be null when expands is true.',
      ),
      assert(!obscureText || maxLines == 1,
          'Obscured fields cannot be multiline.'),
      assert(maxLength == null || maxLength > 0),
      assert(
          !identical(textInputAction, TextInputAction.newline) ||
              maxLines == 1 ||
              !identical(keyboardType, TextInputType.text),
          'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.'),
      keyboardType = keyboardType ??
          (maxLines == 1 ? TextInputType.text : TextInputType.multiline),
      toolbarOptions = toolbarOptions ??
          (obscureText
              ? const ToolbarOptions(
                  selectAll: true,
                  paste: true,
                )
              : const ToolbarOptions(
                  copy: true,
                  cut: true,
                  selectAll: true,
                  paste: true,
                )),
      super(key: key);