FormChipsField<TValue> constructor
FormChipsField<TValue> ({
- Key? key,
- FormController<
TValue> ? form, - FormStyle? style,
- bool enabled = true,
- String? hintText,
- String? labelText,
- FormAffixStyle? prefix,
- FormAffixStyle? suffix,
- bool readOnly = false,
- required ChipBuilder<
String> builder, - ChipBuilder<
String> ? suggestionBuilder, - List<
String> suggestion = const [], - void onChanged()?,
- void onChipTapped(
- String value
- int? maxChips,
- String? emptyErrorText,
- FocusNode? focusNode,
- TextInputType keyboardType = TextInputType.text,
- bool obscureText = false,
- SuggestionStyle? suggestionStyle,
- bool keepAlive = true,
- TValue onSaved()?,
- String validator()?,
- List<
String> initialValue = const [],
Implementation
FormChipsField({
super.key,
this.form,
this.style,
super.enabled,
this.hintText,
this.labelText,
this.prefix,
this.suffix,
this.readOnly = false,
required ChipBuilder<String> builder,
this.suggestionBuilder,
this.suggestion = const [],
this.onChanged,
this.onChipTapped,
this.maxChips,
this.emptyErrorText,
this.focusNode,
this.keyboardType = TextInputType.text,
this.obscureText = false,
this.suggestionStyle,
this.keepAlive = true,
TValue Function(List<String> value)? onSaved,
String Function(List<String>? value)? validator,
List<String> super.initialValue = const [],
}) : _builder = builder,
assert(
(form == null && onSaved == null) ||
(form != null && onSaved != null),
"Both are required when using [form] or [onSaved].",
),
super(
builder: (state) {
return const SizedBox.shrink();
},
onSaved: (value) {
if (value == null) {
return;
}
final res = onSaved?.call(value);
if (res == null) {
return;
}
form!.value = res;
},
validator: (value) {
if (emptyErrorText.isNotEmpty && value.isEmpty) {
return emptyErrorText;
}
return validator?.call(value);
},
);