dummyImage static method

String dummyImage({
  1. String? text,
  2. Size size = const Size(300, 300),
  3. ImageType imageType = ImageType.png,
  4. Color bgColor = Colors.grey,
  5. Color fgColor = Colors.black,
})

Generates a random image URL from dummyimage with the specified dimensions . The width and height parameters specify the dimensions of the image. Returns a string representing the URL of the random image.

Implementation

static String dummyImage({
  String? text,
  Size size = const Size(300, 300),
  ImageType imageType = ImageType.png,
  Color bgColor = Colors.grey,
  Color fgColor = Colors.black,
}) {
  final imageSize = '${size.width.toInt()}x${size.height.toInt()}';
  final imageText = text ?? imageSize;
  final data =
      'https://dummyimage.com/$imageSize.${imageType.name}/${bgColor.toHex(
    leadingHashSign: false,
  )}/${fgColor.toHex(leadingHashSign: false)}&text=$imageText';
  // debugPrint(data);
  return data;
}