CreateFile static method

Future<File?> CreateFile(
  1. String fileName, {
  2. String? path,
  3. String? extensionFile,
})

Implementation

static Future<File?> CreateFile(String fileName, {String? path, String? extensionFile}) async {
  try {
    var file = File((path ?? filePath) + "/" + fileName + "." + (extensionFile ?? "txt"));
    if (!await file.exists()) {
      file = await file.create();
    }
    return file;
  } catch (ex) {
    print(ex);
    return null;
  }
}