filename method

String filename(
  1. String image,
  2. String? tag
)

Formate image and tag to filename format

Implementation

String filename(String image, String? tag) {
  if (image.isEmpty) {
    throw Exception('Image is not valid');
  }
  final filename = image.replaceAll(RegExp(r'[^a-zA-Z0-9]'), '_');
  if (tag == null) {
    return filename;
  }
  final tagFilename = tag.replaceAll(RegExp(r'[^a-zA-Z0-9]'), '_');
  return '${filename}_$tagFilename';
}