Issue
I try to get all files in folder by Stream.
Directort(path).list()
returns Stream<FileSystemEntity>
.
I want returns Stream<List<FileSystemEntity>>
.
Example:
1 => 1
2 => 1,2
3 => 1,2,3
Solution
scan
operator from rxdart
is the best answer
https://pub.dev/documentation/rxdart/latest/rx/ScanExtension/scan.html
https://rxjs.dev/api/operators/scan
Stream<FileSystemEntity> source$ = ...;
Stream<List<FileSystemEntity>> result$ = source$.scan(
(acc, element, _) => [...acc, element],
[],
);
Answered By – Petrus Nguyễn Thái Học
Answer Checked By – Senaida (FlutterFixes Volunteer)