recursive method

Future<void> recursive({
  1. required FutureOr<void> onData(
    1. FileSystemEntity fileSystemEntity
    ),
})

Implementation

Future<void> recursive({
  required FutureOr<void> Function(FileSystemEntity fileSystemEntity) onData,
}) async {
  List<FileSystemEntity> fileSystemEntitys = listSync();

  for (var i = 0; i < fileSystemEntitys.length; i++) {
    FileSystemEntity fileSystemEntity = fileSystemEntitys[i];

    await onData(fileSystemEntity);

    if (fileSystemEntity is Directory) {
      if ((await fileSystemEntity.exists())) {
        await fileSystemEntity.recursive(onData: onData);
      }
    } else if (fileSystemEntity is File) {}
  }
}