randomImage static method
Generates a random image URL from robohash with the specified dimensions and category filter.
The width
and height
parameters specify the dimensions of the image.
The category
parameter specifies the category of the image.
Returns a string representing the URL of the random image.
Implementation
static String randomImage({
String slug = 'my',
Size size = const Size(300, 300),
ImageSet set = ImageSet.any,
ImageBg bg = ImageBg.any,
ImageType imageType = ImageType.png,
String category = 'photo',
ImageColor? color,
}) {
final imageColor =
color != null ? '&color=${color.name.toLowerCase()}' : '';
final data =
'https://robohash.org/$slug.${imageType.name}?size=${size.width.toInt()}x${size.height.toInt()}&set=${set.name}&bgset=${bg.name}$imageColor';
return data;
}