imageFileToBase64 function
Implementation
Future<String> imageFileToBase64(File imageFile) async {
try {
// Read the file as bytes
Uint8List imageBytes = await imageFile.readAsBytes();
// Encode the bytes to Base64
String base64Image = base64Encode(imageBytes);
return base64Image;
} catch (e) {
throw Exception("Error converting image to base64: $e");
}
}