CustomDropdown<T> constructor
const
CustomDropdown<T> ({
- Key? key,
- required String label,
- required T value,
- required List<
DropdownMenuItem< items,T> > - 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,
});