CreditCardCodeField constructor
CreditCardCodeField({
- required CreditCardType creditCardType,
- String validatorMessage = 'Informe o %s.',
- String? labelPrefix,
- String? label,
- TextEditingController? controller,
- String? validator(
- String? value
- TextAlign textAlign = TextAlign.start,
- void onSaved(
- String? value
- String? initialValue,
- bool enabled = true,
- AutovalidateMode autoValidateMode = AutovalidateMode.disabled,
- ValueChanged<
String?> ? onChanged, - FocusNode? focusNode,
- TextInputAction? textInputAction,
- ValueChanged<
String?> ? onFieldSubmitted, - bool autocorrect = false,
- bool enableSuggestions = false,
- TextCapitalization textCapitalization = TextCapitalization.none,
- EdgeInsets scrollPadding = const EdgeInsets.all(20),
- bool enableInteractiveSelection = true,
- bool filled = false,
- Color? fillColor,
- bool required = true,
- Iterable<
String> ? autofillHints, - TextStyle? style,
- InputDecoration? decoration,
- EdgeInsets padding = const EdgeInsets.all(8),
- EdgeInsets? contentPadding,
- String? counterText = '',
- Widget? prefix,
- Widget? prefixIcon,
- Widget? suffix,
- Widget? suffixIcon,
- void onTap()?,
- int? sizeExtraSmall,
- int? sizeSmall,
- int? sizeMedium,
- int? sizeLarge,
- int? sizeExtraLarge,
- double? minHeight,
- Key? key,
Implementation
CreditCardCodeField({
required CreditCardType creditCardType,
String validatorMessage = 'Informe o %s.',
super.labelPrefix,
String? label,
super.controller,
String? Function(String? value)? validator,
super.textAlign,
void Function(String? value)? onSaved,
String? initialValue,
super.enabled,
super.autoValidateMode,
super.onChanged,
super.focusNode,
super.textInputAction,
super.onFieldSubmitted,
super.autocorrect = false,
super.enableSuggestions = false,
super.textCapitalization,
super.scrollPadding,
super.enableInteractiveSelection,
super.filled,
super.fillColor,
bool required = true,
super.autofillHints,
super.style,
super.decoration,
super.padding,
super.contentPadding,
super.counterText,
super.prefix,
super.prefixIcon,
super.suffix,
super.suffixIcon,
super.onTap,
super.sizeExtraSmall,
super.sizeSmall,
super.sizeMedium,
super.sizeLarge,
super.sizeExtraLarge,
super.minHeight,
super.key,
}) : assert(
initialValue == null || controller == null,
'initialValue or controller must be null.',
),
super(
keyboard: TextInputType.number,
label: label ?? creditCardType.code.name,
validator: enabled
? (String? value) {
if (!required && (value == null || value.isEmpty)) {
return null;
}
if (value == null || !creditCardType.cvvCheck(value)) {
return sprintf(
validatorMessage,
<dynamic>[label ?? creditCardType.code.name],
);
}
if (validator != null) {
return validator(value);
}
return null;
}
: null,
minLines: 1,
maxLines: 1,
maxLength: creditCardType.code.size.fold<int>(0, max),
hintText: List<String>.generate(
creditCardType.code.size.fold<int>(0, max),
(_) => 'X',
).join(),
obscureText: false,
inputFormatter: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly,
],
onSaved: enabled
? (String? value) {
if (onSaved != null) {
if (!required && value != null && value.isEmpty) {
value = null;
}
onSaved(value);
}
}
: null,
);