I would like to use a placeholder image file that I\'ve added to my code as \"assets/placeholder.png\"
, but I\'m getting a File not found error. This is how I\
Here is an example to read file byte by byte:
import 'dart:io';
void main(List arguments) {
readFileByteByByte().then((done) {
print('done');
});
print('waiting...');
print('do something else while waiting...');
}
Future readFileByteByByte() async {
//final fileName = 'C:\\code\\test\\file_test\\bin\\main.dart'; // use your image file name here
final fileName = Platform.script.toFilePath(); //this will read this text file as an example
final script = File(fileName);
final file = await script.open(mode: FileMode.read);
var byte;
while (byte != -1) {
byte = await file.readByte();
if (byte == ';'.codeUnitAt(0)) { //check if byte is semicolon
print(byte);
}
}
await file.close();
return (true);
}