dart 仅获取子目录

ttisahbt  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(153)

如何获取目录中的子目录列表?

import 'dart:io';

void main() async {
  // Get the system temp directory.
  var systemTempDir = Directory.systemTemp;

  // List directory contents, not recursing into sub-directories,
  // not following symbolic links.
  await for (var entity in
      systemTempDir.list(recursive: false, followLinks: false)) {
    print(entity.path);
  }
}

字符串

cidc1ykv

cidc1ykv1#

也许是这样的:

import 'dart:io';

void main(List<String> arguments) {
  final dir = Directory.systemTemp;
  final files = dir.listSync();
  // get the subdirectories
  for (final f in files) {
    if (f is Directory) {
      print(f.path);
    }
  }
}

字符串

相关问题