setImages method

Future<void> setImages(
  1. {required AppModel appModel,
  2. required CreatorModel creatorModel,
  3. required Future<List<NetworkToFileImage>> generateImages(
      ),
    1. required EnhancementTriggerCause cause,
    2. required bool newAutoCannotOverride,
    3. String? searchTerm}
    )

    Perform a function that generates a list of images and attempt a search with a given search term.

    Implementation

    Future<void> setImages({
      required AppModel appModel,
      required CreatorModel creatorModel,
      required Future<List<NetworkToFileImage>> Function() generateImages,
      required EnhancementTriggerCause cause,
      required bool newAutoCannotOverride,
      String? searchTerm,
    }) async {
      if (_autoCannotOverride && cause == EnhancementTriggerCause.auto) {
        return;
      }
    
      if (creatorModel.scrollController.hasClients &&
          cause == EnhancementTriggerCause.manual) {
        creatorModel.scrollController
            .jumpTo(creatorModel.scrollController.position.minScrollExtent);
      }
    
      carouselKey = UniqueKey();
    
      /// Show loading state.
      setSearching(
          appModel: appModel,
          creatorModel: creatorModel,
          isSearching: true,
          searchTerm: searchTerm);
      try {
        List<NetworkToFileImage> images = await generateImages();
    
        if (images.isNotEmpty) {
          setSearchSuggestions(
            appModel: appModel,
            creatorModel: creatorModel,
            images: images,
            searchTermUsed: searchTerm,
          );
          _autoCannotOverride = newAutoCannotOverride;
        }
      } finally {
        /// Finish loading state.
        setSearching(
          appModel: appModel,
          creatorModel: creatorModel,
          isSearching: false,
          searchTerm: searchTerm,
        );
      }
    }