I need to convert a local HTML file to a Uint8list so it could be printed. Solutions I’ve found don’t seem to work.
I tried using readAsArrayBuffer but it did not work for me.
void loadImage(html.File file) async {
final reader = html.FileReader();
reader.readAsArrayBuffer(file);
await reader.onLoad.first;
setState(() {
imageData = reader.result as Uint8List;
});
}
2
Answers
You may use the file_picker package for opening local files.
If you want to read a local HTML file in Dart outside of a web environment , you can use the dart:io library for file I/O.