Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemoryFileSystem File.readAsBytesSync() failure #635

Closed
simmule-turner opened this issue Apr 14, 2019 · 4 comments
Closed

MemoryFileSystem File.readAsBytesSync() failure #635

simmule-turner opened this issue Apr 14, 2019 · 4 comments

Comments

@simmule-turner
Copy link

simmule-turner commented Apr 14, 2019

MemoryFileSystem File.readAsBytesSync() produces different results than the default File.readAsBytesSync(). Adding Uint8List.fromList to the resultant bytes corrects the problem.

@simmule-turner simmule-turner changed the title MemoryFileSystem MemoryFileSystem File.readAsBytesSync() failure Apr 14, 2019
@simmule-turner
Copy link
Author

When reading from a local file the data is correct in bytes. Once written to a MemoryFileSystem the data is retrieved incorrectly and requires an extra level of translation before it works. The below code does not work:
List bytes = File(path + '/' + filename).readAsBytesSync();
mfs.file('a
${i}').writeAsBytesSync(bytes);
List xbytes = mfs.file('a_${i}').readAsBytesSync();

The above code does not produce a displayable image from bytes from the original file. However, adding this line allows an image to be displayed properly without other changes (In the example here I use a MemoryImage.
xbytes = Uint8List.fromList(xbytes);

The impact is that a MemoryFileSystem.file can not be used for a FileImage provider.

@simmule-turner
Copy link
Author

LocalFileSystem() has the correct behavior.

@jamesderlin
Copy link
Contributor

I think that this should have been fixed by dart-archive/file.dart#123.

@dnfield
Copy link
Contributor

dnfield commented Jun 11, 2020

Closing on assumption dart-archive/file.dart#123 fixed this

@dnfield dnfield closed this as completed Jun 11, 2020
@devoncarew devoncarew transferred this issue from dart-archive/file.dart Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants