DropdownItem<T>.fromMap constructor

DropdownItem<T>.fromMap(
  1. Map<String, dynamic> map
)

Creates a new instance of DropdownItem from a map.

The map should contain the following keys:

  • 'label': The label of the dropdown item (required).
  • 'value': The value associated with the dropdown item (required).
  • 'disabled': Indicates whether the dropdown item is disabled (optional, default is false).
  • 'selected': Indicates whether the dropdown item is selected (optional, default is false).

Implementation

factory DropdownItem.fromMap(Map<String, dynamic> map) {
  return DropdownItem<T>(
    id: map['id'] as String? ?? '',
    label: map['label'] as String? ?? '',
    value: map['value'] as T,
    disabled: map['disabled'] as bool? ?? false,
    selected: map['selected'] as bool? ?? false,
  );
}