buildDecoration method
Builds the InputDecoration used by this field.
Implementation
InputDecoration buildDecoration(BuildContext context, {String? error}) {
if (decoration != null) {
if (error != null) {
return decoration!.copyWith(errorText: error);
}
return decoration!;
}
final ColorScheme scheme = Theme.of(context).colorScheme;
final OutlineInputBorder border = OutlineInputBorder(
borderRadius: BorderRadius.circular(borderRadius),
borderSide: BorderSide(color: scheme.outlineVariant),
);
return InputDecoration(
labelText: label,
hintText: hint,
errorText: error ?? errorText,
prefixIcon: icon != null ? Icon(icon, size: 20) : null,
prefixText: prefixText,
suffixIcon: suffixIcon,
filled: filled,
border: border,
enabledBorder: border,
focusedBorder: border.copyWith(
borderSide:
BorderSide(color: focusBorderColor ?? scheme.primary, width: 2),
),
errorBorder: border.copyWith(
borderSide: BorderSide(color: scheme.error),
),
focusedErrorBorder: border.copyWith(
borderSide: BorderSide(color: scheme.error, width: 2),
),
);
}