how to convert a file from file.path to base64 in flutter

1k Views Asked by At

I have used filepicker to choose file from internal storage:

Fresult = await FilePicker.platform.pickFiles(
      type: FileType.custom,
      allowedExtensions: ['pdf', 'jpg'],
 PlatformFile file = Fresult.files.first;
      fiLeName=file.name.toString();
      fiLePath=file.path.toString();
    );

and to convert that file suppose a pdf to base64 I used

final bytes = io.File(fiLePath).readAsBytesSync();
String vbase= base64Encode(bytes);

When i print the base64 string which i have received and used an online converter to see if the file is corrupted or not. but fortunately the result is corrupted.

Is there any way to do it? or have I done it wrong? please help me with it

0

There are 0 best solutions below