ImageScopeConfiguration constructor
ImageScopeConfiguration({})
Creates a image configuration with optional descriptions.
This constructor ensures that if descriptions are provided, their count must match the
number of images in imageUrls. If showDescription is true, a mismatch will result
in an ImageScopeError.
Parameters:
imageUrls: List of image URLs to be displayed.descriptions: List of descriptions corresponding to the images (optional).showDescription: Flag to toggle description visibility (optional).
Implementation
ImageScopeConfiguration({
required this.imageUrls,
this.descriptions,
this.showDescription,
}) {
// Check if descriptions are enabled and validate the length
if (showDescription == true) {
if (descriptions != null && descriptions!.length != imageUrls.length) {
throw ImageScopeError(
message:
"Oops! The number of descriptions (${descriptions!.length}) doesn't match the number of images (${imageUrls.length}).",
context: 'Description & Image Mismatch',
solution:
'Ensure that every image has a corresponding description, or leave descriptions null if not needed.',
);
}
}
}