selectInitialValue method

void selectInitialValue()

Implementation

void selectInitialValue() {
  if (widget.initialSelection != null) {
    final int index = (widget.entries as List<FDropdownEntry<T>>).indexWhere(
        (FDropdownEntry<T> entry) =>
            entry.value == (widget.initialSelection as T));

    if (index != -1) {
      selectedValue = widget.entries[index] as FDropdownEntry<T>;
      _controller.text = selectedValue!.label;
    }
  } else {
    selectedValue = null;
    _controller.text = "";
  }
}