我尝试按流获取文件夹中的所有文件。
Directort(path).list()
返回Stream<FileSystemEntity>
。
我要退货Stream<List<FileSystemEntity>>
。
例:
1 => 1
2 => 1,2
3 => 1,2,3
scan
从运营商rxdart
是最好的答案
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],
[],
);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句