createFileIfNotExist function

Future<File> createFileIfNotExist(
  1. String filePath
)

Creates File in the given filePath if not exists

Implementation

Future<File> createFileIfNotExist(String filePath) async {
  final file = File(path.joinAll(path.split(filePath)));
  // Using the sync method here due to `avoid_slow_async_io` lint suggestion.
  if (!file.existsSync()) {
    await file.create(recursive: true);
  }
  return file;
}