getFileData static method

Map<String, dynamic> getFileData({
  1. required File file,
  2. required String fileTitle,
})

Gets the file metadata that is to be consumed by the api

This involves:

  • The image base64 data, a String
  • The content type; whether PNG or JPG
  • The file name
  • The title of the file
  • The language; defaults to English(en)

Implementation

static Map<String, dynamic> getFileData(
    {required File file, required String fileTitle}) {
  return <String, dynamic>{
    'base64data': base64Encode(file.readAsBytesSync()),
    'contentType': file.path.split('/').last.split('.').last.toUpperCase(),
    'filename': file.path.split('/').last,
    'title': fileTitle,
    'language': 'en',
  };
}