buildField method

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

Implementation

@override
Widget buildField(BuildContext context) {
  return DropdownButtonFormField<String>(
    value: widget.value.isEmpty ? null : widget.value,
    items: widget.items
        .map((e) => DropdownMenuItem(value: e.value, child: Text(e.label)))
        .toList(),
    onChanged: (value) {
      widget.setValue(value!);
    },
    decoration: InputDecoration(
      labelText: widget.label,
      suffixIcon: widget.value.isEmpty ? null : buildClearIcon(),
    ),
    isExpanded: true,
    validator: widget.fieldValidator,
  );
}