0

So basically i want to select the files from my device and encrypt them with the help of bytes. I am done with the selection part and have done that using file picker if anyone can help me how to get bytes of the file i have selected it would be really helpful. here is my code to pick files from device


void selectFileFromDevice(d) async{
  FilePickerResult filePickerResult = await FilePicker.platform.pickFiles(allowMultiple: true);
  if(filePickerResult!=null){
    List<io.File> files = filePickerResult.paths.map((path) => io.File(path)).toList();
    
  }else{
    print('user cancelled the picker');
  }
}

the above code is working absolutely fine i just want to know how can get the bytes of my selected files. Thank you

yogender
  • 202
  • 3
  • 12

1 Answers1

1

you can use the following code to get the bytes of your file

Uint8List  bytes = await  files[0].readAsBytes();
Nishuthan S
  • 1,538
  • 3
  • 12
  • 30