buildInputDecoration method

InputDecoration buildInputDecoration(
  1. Set<WidgetState> states, {
  2. bool expands = false,
  3. Widget? beforePostWidget,
  4. Widget? beforePreWidget,
  5. String? label,
  6. String? placeholder,
  7. String? tag,
  8. String? helperText,
  9. List<String>? errors,
  10. bool isRequired = false,
  11. VoidCallback? onClear,
  12. 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);

  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,
    constraints: BoxConstraints(minHeight: fieldHeight, maxHeight: expands ? double.infinity : fieldHeight),
    hintText: placeholder,
    hintStyle: hintStyle.resolve(states),
    prefixIcon: _buildPreWidget(beforePreWidget),
    suffixIcon: _buildPostWidget(
        beforePostWidget: beforePostWidget, onClear: onClear, infoIcon: labelPosition == TLabelPosition.floating ? infoIcon : null),
    filled: decorationType == TInputDecorationType.filled,
    fillColor: backgroundColor.resolve(states),
  );
}