CustomDropdown<T> constructor

const CustomDropdown<T>({
  1. Key? key,
  2. required String label,
  3. required T value,
  4. required List<DropdownMenuItem<T>> items,
  5. required ValueChanged<T?> onChanged,
})

Creates a CustomDropdown with the required parameters

The label is displayed above the dropdown. The value represents the currently selected item. The items list contains all available options. The onChanged callback is called when the selection changes.

Example:

// For a country selector
CustomDropdown<String>(
  label: 'Country',
  value: selectedCountry,
  items: countries.map((country) {
    return DropdownMenuItem(
      value: country.code,
      child: Text(country.name),
    );
  }).toList(),
  onChanged: (value) => setState(() => selectedCountry = value!),
)

Implementation

const CustomDropdown({
  super.key,
  required this.label,
  required this.value,
  required this.items,
  required this.onChanged,
});