delDir function Null safety

Future<FileSystemEntity?> delDir(
  1. FileSystemEntity file
)

递归方式删除目录

Implementation

Future<FileSystemEntity?> delDir(FileSystemEntity file) async {
  try {
    if (file.existsSync()) {
      if (file is Directory) {
        final List<FileSystemEntity> children = file.listSync();
        for (final FileSystemEntity child in children) {
          await delDir(child);
        }
      }
      return await file.delete();
    }
  } catch (e) {
    print('递归删除文件目录异常: $e');
    return Future<FileSystemEntity?>.value(null);
  }
}