writeFile method

Future<File> writeFile({
  1. required String filePath,
  2. required String content,
})

Writes the provided content to a file at the specified filePath. Parameters:

  • filePath: The path of the file to be written to.
  • content: The content to be written to the file. Returns: Future

Implementation

Future<File> writeFile({
  required String filePath,
  required String content,
}) async {
  try {
    return await File(filePath).writeAsString(content);
  } catch (e) {
    throw FileWriteException(
      filePath: filePath,
      platform: platform,
      details: e.toString(),
    );
  }
}