Skip to content

listDocumentsStream blocks when readAsBytes is called inside the stream iteration #19

@xioxin

Description

@xioxin

Is there an existing issue or discussion for this?

  • I have searched the existing issues & discussions

Primary Information

- Flutter (Channel main, 3.38.0-1.0.pre-330)
- docman 1.2.0

Steps to Reproduce

I'm encountering an issue where calling readAsBytes() inside a listDocumentsStream() iteration causes the stream to block indefinitely. The stream stops emitting new events and never completes.

Expected Behavior

The stream should continue emitting all files in the directory
Each file should be processed and both "File: [name]" and "test" should be printed for every file
The stream should complete normally after all files are processed

Current/Actual Behavior

Only the first file is processed completely
The stream blocks after the first iteration
No additional files are emitted and the stream never completes

Code sample

Code sample
final dir = await DocumentFile.fromUri(source.paths[0]);
await for (final file in dir!.listDocumentsStream()) {
  if (file.isDirectory) continue;
  print("File: ${file.name}");
  file.readAsBytes().last.then((v) {
    print("test");
  });
}

Screenshots or Video

No response

Debug Information, Logs

Logs / Debug information
I/flutter (21771): File: IMG_7182.JPG
I/flutter (21771): test
[No further output - stream blocks]

Possible Solution

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions