buildInputDecoration method
InputDecoration
buildInputDecoration(
- Set<WidgetState> states, {
- bool expands = false,
- Widget? beforePostWidget,
- Widget? beforePreWidget,
- String? label,
- String? placeholder,
- String? tag,
- String? helperText,
- List<String>? errors,
- bool isRequired = false,
- VoidCallback? onClear,
- Widget? infoIcon,
})
Implementation
InputDecoration buildInputDecoration(
Set<WidgetState> states, {
bool expands = false,
Widget? beforePostWidget,
Widget? beforePreWidget,
String? label,
String? placeholder,
String? tag,
String? helperText,
List<String>? errors,
bool isRequired = false,
VoidCallback? onClear,
Widget? infoIcon,
}) {
final inputBorder = buildInputBorder(states);
final hasPrefix = beforePreWidget != null || preWidget != null;
final hasSuffix = onClear != null || beforePostWidget != null || infoIcon != null || postWidget != null;
return InputDecoration(
border: inputBorder,
enabledBorder: inputBorder,
focusedErrorBorder: inputBorder,
disabledBorder: inputBorder,
focusedBorder: inputBorder,
errorBorder: inputBorder,
contentPadding: fieldPadding,
label: labelPosition == TLabelPosition.aboveField ? null : labelBuilder.resolve(states)(label, tag, isRequired, null),
labelStyle: labelStyle.resolve(states),
floatingLabelStyle: labelStyle.resolve(states),
floatingLabelBehavior: switch (labelPosition) {
TLabelPosition.aboveField => FloatingLabelBehavior.never,
TLabelPosition.floating => FloatingLabelBehavior.auto,
},
isDense: true,
visualDensity: VisualDensity.compact,
hintText: placeholder,
hintStyle: hintStyle.resolve(states),
prefixIconConstraints: BoxConstraints(minHeight: fieldHeight, minWidth: hasPrefix ? 40 : 7.5),
prefixIcon: _buildPreWidget(beforePreWidget),
suffixIconConstraints: BoxConstraints(minHeight: fieldHeight, minWidth: hasSuffix ? 40 : 7.5),
suffixIcon: _buildPostWidget(
beforePostWidget: beforePostWidget, onClear: onClear, infoIcon: labelPosition == TLabelPosition.floating ? infoIcon : null),
filled: decorationType == TInputDecorationType.filled,
fillColor: backgroundColor.resolve(states),
);
}