ensureFileExists static method

Future<void> ensureFileExists(
  1. String path, {
  2. bool force = false,
})

Implementation

static Future<void> ensureFileExists(
  String path, {
  bool force = false,
}) async {
  final file = File(path);
  if (force && await file.exists()) {
    await file.delete();
  }
  if (!await file.exists()) {
    await file.create(recursive: true);
  }
}