I have an error in "file", it shows me a red line. I'm trying to load images. I'm using Flutter 3.0.4. I'm using file_saver: 0.1.1, open_file: 3.2.1. I don't know what could be the error. Could you please help me.
class ImageLoader {
ui.Codec frames;
String url;
Map<String, dynamic> requestHeaders;
LoadState state = LoadState.loading; // by default
ImageLoader(this.url, {this.requestHeaders});
void loadImage(VoidCallback onComplete) {
if (this.frames != null) {
this.state = LoadState.success;
onComplete();
}
final fileStream = DefaultCacheManager().getFileStream(this.url,
headers: this.requestHeaders as Map<String, String>);
fileStream.listen(
(fileResponse) {
if (!(fileResponse is FileInfo)) return;
if (this.frames != null) {
return;
}
final imageBytes = fileResponse.file.readAsBytesSync();
this.state = LoadState.success;
PaintingBinding.instance.instantiateImageCodec(imageBytes).then(
(codec) {
this.frames = codec;
onComplete();
}, onError: (error) {
this.state = LoadState.failure;
onComplete();
});
},
onError: (error) {
this.state = LoadState.failure;
onComplete();
},
);
}
}