setSearchSuggestions method

void setSearchSuggestions(
  1. {required AppModel appModel,
  2. required CreatorModel creatorModel,
  3. required List<NetworkToFileImage> images,
  4. String? searchTermUsed,
  5. int newSelectedSuggestionIndex = 0}
)

Takes a non-empty new list of images to set as the new image suggestions. By default, this replaces the exportFile with the index set in newSelectedSuggestionIndex.

Implementation

void setSearchSuggestions({
  required AppModel appModel,
  required CreatorModel creatorModel,
  required List<NetworkToFileImage> images,
  String? searchTermUsed,
  int newSelectedSuggestionIndex = 0,
}) {
  creatorModel.getFieldController(this).clear();
  if (images.isEmpty ||
      newSelectedSuggestionIndex < 0 &&
          newSelectedSuggestionIndex >= images.length) {
    clearFieldState(
      creatorModel: creatorModel,
    );
  }

  _imageSuggestions = images;
  _exportFile = images.first;
  _indexNotifier.value = newSelectedSuggestionIndex;
  _currentSearchTerm = searchTermUsed;
  _isSearching = false;
  creatorModel.refresh();
  carouselNotifier.notifyListeners();
}