generatePath method

Future<void> generatePath(
  1. String path, {
  2. bool forceGenerate = false,
  3. bool isFile = true,
  4. bool printError = false,
})

Implementation

Future<void> generatePath(
  String path, {
  bool forceGenerate = false,
  bool isFile = true,
  bool printError = false,
}) async {
  final io = isFile ? File(path) : Directory(path);
  final isExists = await io.exists();
  if (!forceGenerate && isExists) {
    if (printError) print('$path Exists Before');
    throw IOFailure(cause: '$path Exists Before');
  }
  if (io is Directory) await io.create(recursive: true);
  if (io is File) await io.create(recursive: true);
}