ChipsChoice<T>.single constructor

ChipsChoice<T>.single({
  1. Key? key,
  2. required T? value,
  3. required C2Changed<T> onChanged,
  4. List<C2Choice<T>> choiceItems = const [],
  5. C2ChoiceLoader<T>? choiceLoader,
  6. C2ChipStyle? choiceStyle,
  7. bool choiceCheckmark = false,
  8. C2Builder<T>? choiceLabelBuilder,
  9. C2Builder<T>? choiceLeadingBuilder,
  10. C2Builder<T>? choiceTrailingBuilder,
  11. C2Builder<T>? choiceBuilder,
  12. WidgetBuilder? spinnerBuilder,
  13. WidgetBuilder? placeholderBuilder,
  14. WidgetBuilder? errorBuilder,
  15. bool wrapped = false,
  16. EdgeInsetsGeometry? padding,
  17. Axis direction = Axis.horizontal,
  18. VerticalDirection verticalDirection = VerticalDirection.down,
  19. TextDirection? textDirection,
  20. Clip clipBehavior = Clip.hardEdge,
  21. ScrollPhysics? scrollPhysics,
  22. MainAxisSize mainAxisSize = MainAxisSize.max,
  23. MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
  24. CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
  25. WrapAlignment alignment = WrapAlignment.start,
  26. WrapAlignment runAlignment = WrapAlignment.start,
  27. WrapCrossAlignment wrapCrossAlignment = WrapCrossAlignment.center,
  28. double spacing = 10,
  29. double runSpacing = 10,
  30. String? placeholder,
  31. TextStyle? placeholderStyle,
  32. TextAlign? placeholderAlign,
  33. TextStyle? errorStyle,
  34. TextAlign? errorAlign,
  35. double? spinnerSize,
  36. Color? spinnerColor,
  37. double? spinnerThickness,
  38. Widget? leading,
  39. Widget? trailing,
  40. ScrollController? scrollController,
  41. bool scrollToSelectedOnChanged = false,
})

Constructor for single choice

The value is current selected value

The onChanged called when value changed

The choiceItems is List of C2Choice item to generate the choices

The choiceLoader is function to load the choice items

The choiceStyle is a configuration for styling unselected choice widget

The choiceActiveStyle is a configuration for styling selected choice widget

The choiceLabelBuilder is builder for custom label of the choice item

The choiceAvatarBuilder is builder for custom avatar of the choice item

The choiceBuilder is builder for custom choice item widget

The spinnerBuilder is builder for custom spinner widget

The placeholderBuilder is builder for custom placeholder widget

The errorBuilder is builder for custom error widget

The wrapped is whether the chips is wrapped or scrollable

The padding is padding of the list container

The direction is the direction to use as the main axis

The verticalDirection is determines the order to lay children out vertically and how to interpret start and end in the vertical direction

The textDirection is determines the order to lay children out horizontally and how to interpret start and end in the horizontal direction

The clipBehavior is clip behavior of the list container

The scrollPhysics is how the scroll view should respond to user input, if Wrapped is false

The mainAxisSize is how much space should be occupied in the main axis, if wrapped is false

The mainAxisAlignment is how the children should be placed along the main axis, if wrapped is false

The crossAxisAlignment is how the children should be placed along the cross axis, if wrapped is false

The alignment is determines how wrap will align the objects, if wrapped is true

The runAlignment is how the runs themselves should be placed in the cross axis, if wrapped is true

The wrapCrossAlignment is how the children within a run should be aligned relative to each other in the cross axis, if wrapped is true

The spacing is how much space to place between children in a run in the main axis, if wrapped is true

The runSpacing is how much space to place between the runs themselves in the cross axis, if wrapped is true

The placeholder is string to display when there is no choice items

The placeholderStyle is text style for default placeholder widget

The placeholderAlign is text align for default placeholder widget

The errorStyle is text style for default error widget

The errorAlign is text align for default error widget

The spinnerSize is size of the default spinner widget

The spinnerColor is color of the default spinner widget

The spinnerThickness is thickness of the default spinner widget

The leading is custom widget that inserted before the first choice item

The trailing is custom widget that inserted after the last choice item

The scrollController used when the choice items is scrollable or wrapped is not true

Implementation

ChipsChoice.single({
  Key? key,
  required T? value,
  required C2Changed<T> onChanged,
  this.choiceItems = const [],
  this.choiceLoader,
  this.choiceStyle,
  this.choiceCheckmark = false,
  this.choiceLabelBuilder,
  this.choiceLeadingBuilder,
  this.choiceTrailingBuilder,
  this.choiceBuilder,
  this.spinnerBuilder,
  this.placeholderBuilder,
  this.errorBuilder,
  this.wrapped = false,
  this.padding,
  this.direction = Axis.horizontal,
  this.verticalDirection = VerticalDirection.down,
  this.textDirection,
  this.clipBehavior = Clip.hardEdge,
  this.scrollPhysics,
  this.mainAxisSize = MainAxisSize.max,
  this.mainAxisAlignment = MainAxisAlignment.start,
  this.crossAxisAlignment = CrossAxisAlignment.center,
  this.alignment = WrapAlignment.start,
  this.runAlignment = WrapAlignment.start,
  this.wrapCrossAlignment = WrapCrossAlignment.center,
  this.spacing = 10,
  this.runSpacing = 10,
  this.placeholder,
  this.placeholderStyle,
  this.placeholderAlign,
  this.errorStyle,
  this.errorAlign,
  this.spinnerSize,
  this.spinnerColor,
  this.spinnerThickness,
  this.leading,
  this.trailing,
  this.scrollController,
  this.scrollToSelectedOnChanged = false,
})  : assert(
        choiceItems.isNotEmpty || choiceLoader != null,
        'One of the parameters must be provided',
      ),
      isMultiChoice = false,
      singleValue = value,
      singleOnChanged = onChanged,
      multiValue = const [],
      multiOnChanged = null,
      super(key: key);