ChipsInput<T extends Object> constructor

const ChipsInput<T extends Object>({
  1. Key? key,
  2. required ChipsBuilder<T> chipBuilder,
  3. SuggestionBuilder<T>? suggestionBuilder,
  4. required ChipsInputSuggestions<T> findSuggestions,
  5. AutocompleteOptionsViewBuilder<T>? optionsViewBuilder,
  6. int? maxChips,
  7. List<T> initialValue = const [],
  8. TextEditingController? controller,
  9. MaxLengthEnforcement? maxLengthEnforcement,
  10. FocusNode? focusNode,
  11. InputDecoration? decoration = const InputDecoration(),
  12. TextInputType? keyboardType,
  13. TextInputAction? textInputAction,
  14. TextCapitalization textCapitalization = TextCapitalization.none,
  15. TextStyle? style,
  16. StrutStyle? strutStyle,
  17. TextAlign textAlign = TextAlign.start,
  18. TextAlignVertical? textAlignVertical,
  19. TextDirection? textDirection,
  20. bool readOnly = false,
  21. ToolbarOptions? toolbarOptions,
  22. bool? showCursor,
  23. bool autofocus = false,
  24. String obscuringCharacter = '•',
  25. bool obscureText = false,
  26. bool autocorrect = true,
  27. SmartDashesType? smartDashesType,
  28. SmartQuotesType? smartQuotesType,
  29. int? maxLines = 1,
  30. int? minLines,
  31. bool expands = false,
  32. int? maxLength,
  33. ValueChanged<List<T>>? onChanged,
  34. VoidCallback? onEditingComplete,
  35. AppPrivateCommandCallback? onAppPrivateCommand,
  36. List<TextInputFormatter>? inputFormatters,
  37. bool? enabled,
  38. double cursorWidth = 2.0,
  39. double? cursorHeight,
  40. Radius? cursorRadius,
  41. Color? cursorColor,
  42. BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
  43. BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
  44. Brightness? keyboardAppearance,
  45. EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  46. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  47. bool enableInteractiveSelection = true,
  48. TextSelectionControls? selectionControls,
  49. GestureTapCallback? onTap,
  50. MouseCursor? mouseCursor,
  51. InputCounterWidgetBuilder? buildCounter,
  52. ScrollController? scrollController,
  53. ScrollPhysics? scrollPhysics,
  54. String? restorationId,
})

Implementation

const ChipsInput({
  Key? key,
  required this.chipBuilder,
  this.suggestionBuilder,
  required this.findSuggestions,
  this.optionsViewBuilder,
  this.maxChips,
  this.initialValue = const [],
  this.controller,
  this.maxLengthEnforcement,
  this.focusNode,
  this.decoration = const InputDecoration(),
  TextInputType? keyboardType,
  this.textInputAction,
  this.textCapitalization = TextCapitalization.none,
  this.style,
  this.strutStyle,
  this.textAlign = TextAlign.start,
  this.textAlignVertical,
  this.textDirection,
  this.readOnly = false,
  ToolbarOptions? toolbarOptions,
  this.showCursor,
  this.autofocus = false,
  this.obscuringCharacter = '•',
  this.obscureText = false,
  this.autocorrect = true,
  SmartDashesType? smartDashesType,
  SmartQuotesType? smartQuotesType,
  this.maxLines = 1,
  this.minLines,
  this.expands = false,
  this.maxLength,
  this.onChanged,
  this.onEditingComplete,
  this.onAppPrivateCommand,
  this.inputFormatters,
  this.enabled,
  this.cursorWidth = 2.0,
  this.cursorHeight,
  this.cursorRadius,
  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.selectionControls,
  this.onTap,
  this.mouseCursor,
  this.buildCounter,
  this.scrollController,
  this.scrollPhysics,
  this.restorationId,
})  : 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(
        (suggestionBuilder != null) || (optionsViewBuilder != null),
        "suggestionBuilder or optionsViewBuilder must be be provided",
      ),
      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 == TextField.noMaxLength ||
          maxLength > 0),
      // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
      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);