readFileInputElementAsDataURLBase64 function

Future<String?> readFileInputElementAsDataURLBase64(
  1. FileUploadInputElement? input, [
  2. bool removeExifFromImage = false
])

Reads selected file of input as DATA URL Base64.

Implementation

Future<String?> readFileInputElementAsDataURLBase64(
    FileUploadInputElement? input,
    [bool removeExifFromImage = false]) async {
  if (input == null || input.files == null || input.files!.isEmpty) return null;

  var file = input.files!.first;

  String? data;
  if (removeExifFromImage) {
    var dataURL = await removeExifFromImageFile(file);
    data = dataURL;
  }
  data ??= await readFileDataAsDataURLBase64(file);

  return data;
}