ReactiveMultipleBlockColorPicker<T> constructor
ReactiveMultipleBlockColorPicker<T> ({
- Key? key,
- String? formControlName,
- FormControl<
T> ? formControl, - Map<
String, ValidationMessageFunction> ? validationMessages, - ControlValueAccessor<
T, double> ? valueAccessor, - ShowErrorsFunction<
T> ? showErrors, - InputDecoration? decoration,
- Color? pickerColor,
- List<
Color> availableColors = _defaultColors, - PickerLayoutBuilder? layoutBuilder,
- PickerItemBuilder itemBuilder = _defaultItemBuilder,
- double disabledOpacity = 0.5,
- bool useInShowDialog = true,
Creates a ReactiveMultipleBlockColorPicker that wraps the function showDatePicker.
Can optionally provide a formControl
to bind this widget to a control.
Can optionally provide a formControlName
to bind this ReactiveFormField
to a FormControl
.
Must provide one of the arguments formControl
or a formControlName
,
but not both at the same time.
Implementation
ReactiveMultipleBlockColorPicker({
Key? key,
String? formControlName,
FormControl<T>? formControl,
Map<String, ValidationMessageFunction>? validationMessages,
ControlValueAccessor<T, double>? valueAccessor,
ShowErrorsFunction<T>? showErrors,
////////////////////////////////////////////////////////////////////////////
InputDecoration? decoration,
Color? pickerColor,
List<Color> availableColors = _defaultColors,
PickerLayoutBuilder? layoutBuilder,
PickerItemBuilder itemBuilder = _defaultItemBuilder,
double disabledOpacity = 0.5,
bool useInShowDialog = true,
}) : super(
key: key,
formControl: formControl,
formControlName: formControlName,
validationMessages: validationMessages,
builder: (field) {
final isEmptyValue =
field.value == null || field.value.toString().isEmpty;
final InputDecoration effectiveDecoration = (decoration ??
const InputDecoration())
.applyDefaults(Theme.of(field.context).inputDecorationTheme);
return IgnorePointer(
ignoring: !field.control.enabled,
child: Opacity(
opacity: field.control.enabled ? 1 : disabledOpacity,
child: Listener(
onPointerDown: (_) => field.control.markAsTouched(),
child: InputDecorator(
decoration: effectiveDecoration.copyWith(
errorText: field.errorText,
enabled: field.control.enabled,
),
isEmpty:
isEmptyValue && effectiveDecoration.hintText == null,
child: MultipleChoiceBlockPicker(
pickerColors: field.value ?? [Colors.transparent],
availableColors: availableColors,
onColorsChanged: field.didChange,
useInShowDialog: useInShowDialog,
layoutBuilder: layoutBuilder ??
(BuildContext context, List<Color> colors,
PickerItem child) {
return Wrap(
children: colors
.map((Color color) => child(color))
.toList(),
);
},
itemBuilder: itemBuilder,
),
),
),
),
);
},
);