UIDropDownBloc constructor

UIDropDownBloc(
  1. IuITemplateLocalDatasource localDS,
  2. List<String> options,
  3. String? value, {
  4. String localKey = "ui_dropdown_bloc_value",
})

Implementation

UIDropDownBloc(this.localDS, this.options, this.value, {this.localKey = "ui_dropdown_bloc_value"}):super(UIDropDownLoadingState()){
  localDS.cacheDropDownValue(localKey, value ?? "");
  emit(UIDropdownInitState(value ?? options.first, options));
  on<UIDropDownSelectItemEvent>((event, emit) async {
    _toLoadingState();
    value = event.value;
    localDS.cacheDropDownValue(localKey, value ?? "");
    emit(UIDropdownInitState(event.value, options));
  });
  on<UIDropDownShowErrorEvent>((event, emit) {
    _toLoadingState();
    emit(UIDropDownErrorState(event.message, options, value ?? ""));
  });
  on<UIDropDownProcessingEvent>((event, emit) {
    _toLoadingState();
  });
}