SelectOneBloc<T> constructor

SelectOneBloc<T>(
  1. List<T>? items,
  2. Future<List<T>?> onFind(
    1. String text
    )?,
  3. TextEditingController? findController
)

Implementation

SelectOneBloc(List<T>? items, Future<List<T>?> Function(String text)? onFind, TextEditingController? findController) {
  this.findController = findController ?? TextEditingController();
  _list$ = BehaviorSubject.seeded(items);

  _filteredListOfflineOut = CombineLatestStream.combine2(_list$, _filter$, filter);
  _filteredListOnlineOut = _filter$.where((_) => onFind != null).distinct().debounceTime(Duration(milliseconds: 500)).switchMap((val) => Stream.fromFuture(onFind!(val)).startWith(null));
  filteredListOut = MergeStream([
    _filteredListOfflineOut,
    _filteredListOnlineOut
  ]);

  this.findController.addListener(() => onTextChanged(this.findController.text));
  onTextChanged(this.findController.text);
}