getBasicFile static method

Future getBasicFile(
  1. String keyPath
)

basic 统一文件类的存放目录

Implementation

static Future getBasicFile(String keyPath) async {
  Directory directory;
  if (cacheDirectory != null) {
    directory = Directory(cacheDirectory!);
  } else {
    directory = await getTemporaryDirectory();
    cacheDirectory = directory.path;
  }
  String distPath = '${directory.path}/$kFileBasic/$keyPath';
  final tmpFile = File(distPath);
  if (tmpFile.existsSync()) {
    return tmpFile;
  } else {
    try {
      final tmpDir = await tmpFile.create(recursive: true);
      return tmpDir;
    } catch (e) {
      rethrow;
    }
  }
}