buildField method

  1. @override
Widget buildField(
  1. BuildContext context
)

Implementation

@override
Widget buildField(BuildContext context) {
  return FormField<String>(
      validator: widget.fieldValidator,
      builder: (fieldState) {
        return Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            GestureDetector(
              onTap: _selectDate,
              child: InputDecorator(
                  isEmpty: selected == null,
                  isFocused: isFocused,
                  decoration: InputDecoration(
                      labelText: widget.label,
                      suffixIcon: selected == null ? null : buildClearIcon()),
                  child: selected == null
                      ? const Text("")
                      : Text(formatDate(selected!))),
            ),
            if (fieldState.hasError)
              Text(fieldState.errorText!,
                  style:
                      TextStyle(color: Theme.of(context).colorScheme.error))
          ],
        );
      });
}