setImages method
- {required AppModel appModel,
- required CreatorModel creatorModel,
- required Future<
List< generateImages(NetworkToFileImage> > - required EnhancementTriggerCause cause,
- required bool newAutoCannotOverride,
- 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,
);
}
}