TypeSelector<T> constructor

TypeSelector<T>({
  1. required List<T> options,
  2. bool multiple = false,
  3. dynamic value,
  4. dynamic onValueChanged,
  5. dynamic values,
  6. dynamic onValuesChanged,
  7. dynamic maxQuantityValues,
  8. dynamic onMaxQuantityValues,
  9. Duration transitionDuration = const Duration(milliseconds: 250),
  10. EdgeInsets contentPadding = const EdgeInsets.all(8.0),
  11. TextOverflow valueLabelOverflow = TextOverflow.clip,
  12. bool toggleOptionOnTap = false,
  13. double separatorWidth = 2.0,
  14. double height = 50.0,
  15. double? optionWidth,
  16. String setValueLabel(
    1. T value
    )?,
  17. TextStyle? valueLabelStyle,
  18. Color? activeColor,
  19. Color? disabledColor,
  20. dynamic comparingBy(
    1. T value
    )?,
})

The default TypeSelector constructor that render a rounded corner TypeSelector.

  • options: It's required;
  • multiple: Default is false;
  • value: It's required if [multiple] flag is false;
  • onValueChanged: It's required if [multiple] flag is false;
  • values: It's required if [multiple] flag is true;
  • onValuesChanged: It's required if [multiple] flag is true;
  • onMaxQuantityValues: It's optional;
  • transitionDuration: Default is Duration(milliseconds: 250);
  • contentPadding: Default is EdgeInsets.all(8.0);
  • valueLabelOverflow: Default is TextOverflow.clip;
  • toggleOptionOnTap: Default is false;
  • separatorWidth: Default is 2.0;
  • height: Default is 50.0;
  • optionWidth: Default is constraints.maxWidth / 3.5;
  • setValueLabel: Default is value;
  • valueLabelStyle: Default is TextStyle(color: Colors.white);
  • activeColor: Default is Theme.of(context).accentColor;
  • comparingBy: Default is ==;

Implementation

TypeSelector({
  required this.options,
  this.multiple = false,
  value,
  onValueChanged,
  values,
  onValuesChanged,
  maxQuantityValues,
  onMaxQuantityValues,
  this.transitionDuration = const Duration(milliseconds: 250),
  this.contentPadding = const EdgeInsets.all(8.0),
  this.valueLabelOverflow = TextOverflow.clip,
  this.toggleOptionOnTap = false,
  this.separatorWidth = 2.0,
  this.height = 50.0,
  this.optionWidth,
  this.setValueLabel,
  this.valueLabelStyle,
  this.activeColor,
  this.disabledColor,
  this.comparingBy,
})  : this.value = multiple ? null : value,
      this.onValueChanged = multiple ? null : onValueChanged,
      this.values = multiple ? values ?? [] : null,
      this.onValuesChanged = multiple ? onValuesChanged : null,
      this.maxQuantityValues =
          multiple ? maxQuantityValues ?? options.length : null,
      this.onMaxQuantityValues = multiple ? onMaxQuantityValues : null,

      /// Set shape to a [rounded corner].
      this._borderRadius = 8.0,

      /// Assert [options] list contains at least 2 elements.
      assert(options.length >= 2,
          "The 'options' list must contain at least 2 elements");