imageUrl static method
Generate a random image URL with customizable options.
Parameters:
width
: The width of the image.height
: The height of the image.grayscale
: Whether the image should be in grayscale.blur
: The level of blur (e.g.,5
for a moderate blur).
Implementation
static String imageUrl({
int width = 400,
int height = 200,
bool grayscale = false,
int blur = 0,
}) {
final randomInt = _random.nextInt(1000);
// Base URL
String url = 'https://picsum.photos/$width/$height?random=$randomInt';
// Add grayscale if needed
if (grayscale) {
url += '&grayscale';
}
// Add blur if needed
if (blur > 0) {
url += '&blur=$blur';
}
return url;
}