Read specific chunk of bytes in flutter / dart

Viewed 1037

Is there any way to read just a chunk of bytes from a file in flutter not the whole data? For example from byte 50 to 150

1 Answers

I found the solution myself:

Directory directory = await getApplicationDocumentsDirectory();
File file = File('${directory.path}/myfile.txt');
RandomAccessFile raf= file.openSync(mode: FileMode.read);
raf.setPositionSync(50);
Uint8List data = raf.readSync(100);
Related