TypeSelector<T> constructor
TypeSelector<T> ({
- required List<
T> options, - bool multiple = false,
- dynamic value,
- dynamic onValueChanged,
- dynamic values,
- dynamic onValuesChanged,
- dynamic maxQuantityValues,
- dynamic onMaxQuantityValues,
- Duration transitionDuration = const Duration(milliseconds: 250),
- EdgeInsets contentPadding = const EdgeInsets.all(8.0),
- TextOverflow valueLabelOverflow = TextOverflow.clip,
- bool toggleOptionOnTap = false,
- double separatorWidth = 2.0,
- double height = 50.0,
- double? optionWidth,
- String setValueLabel(
- T value
- TextStyle? valueLabelStyle,
- Color? activeColor,
- Color? disabledColor,
- dynamic comparingBy(
- 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");