Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read specific chunk of bytes in flutter / dart

Tags:

flutter

dart

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

like image 548
Mostafa Solati Avatar asked Mar 02 '23 11:03

Mostafa Solati


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);
like image 182
Mostafa Solati Avatar answered Mar 29 '23 12:03

Mostafa Solati