DfSearchableDropdown<T> constructor

const DfSearchableDropdown<T>({
  1. Key? key,
  2. List<DropDownModel<T>> initData = const [],
  3. DropDownModel<T>? selectedValue,
  4. String? labelText,
  5. String? hintText,
  6. dynamic onOptionSelected(
    1. DropDownModel<T>?
    )?,
  7. String? validator(
    1. DropDownModel<T>?
    )?,
  8. Future<List<DropDownModel<T>>> onSearch(
    1. String searchText
    )?,
  9. DropdownDecoration? decoration,
  10. SimpleSelectorDecoration? selectorDecoration,
  11. Widget? arrowWidget,
  12. DropdownType dropdownType = DropdownType.expandable,
  13. bool disabled = false,
  14. bool closeOnTapOutside = true,
  15. bool rememberSelectedValue = true,
  16. Future<List<DropDownModel<T>>>? asyncInitData,
  17. double expandableSelectorBottomMargin = 4,
})

Constructor for DfSearchableDropdown.

  • initData: Initial list of data for the dropdown.
  • selectedValue: Currently selected value.
  • labelText: Text for the label of the dropdown.
  • hintText: Placeholder text shown when no value is selected.
  • onOptionSelected: Callback function triggered when an option is selected.
  • validator: Optional validation function for the dropdown selection.
  • onSearch: Function to perform a search based on user input, returning a filtered list of dropdown options.
  • decoration: Custom styling for the dropdown field.
  • selectorDecoration: Additional custom styling for the dropdown selector.
  • arrowWidget: Widget for the arrow icon displayed in the dropdown.
  • dropdownType: Default value is DropdownType.expandable, and it's used to switch between the expandable, and the overlay appearance

Implementation

const DfSearchableDropdown({
  super.key,
  this.initData = const [],
  this.selectedValue,
  this.labelText,
  this.hintText,
  this.onOptionSelected,
  this.validator,
  this.onSearch,
  this.decoration,
  this.selectorDecoration,
  this.arrowWidget,
  this.dropdownType = DropdownType.expandable,
  this.disabled = false,
  this.closeOnTapOutside = true,
  this.rememberSelectedValue = true,
  this.asyncInitData,
  this.expandableSelectorBottomMargin = 4,
}) : assert(initData.length == 0 || asyncInitData == null,
          "initData and asyncInitData cannot be provided at the same time");