imageToBase64DataUrl property
Implementation
Future<String> get imageToBase64DataUrl async {
final file = File(this);
if (!await file.exists()) {
throw Exception('Image file not found: $this');
}
final bytes = await file.readAsBytes();
final base64Image = base64Encode(bytes);
final mimeType = lookupMimeType(this) ?? 'image/jpeg';
return 'data:$mimeType;base64,$base64Image';
}