writeTextFileAsync function

Future<void> writeTextFileAsync(
  1. String file,
  2. String contents, {
  3. bool dontLogContents = false,
  4. Encoding encoding = utf8,
  5. bool recursive = false,
})

Creates file and writes contents to it.

If dontLogContents is true, the contents of the file will never be logged.

Implementation

Future<void> writeTextFileAsync(
  String file,
  String contents, {
  bool dontLogContents = false,
  Encoding encoding = utf8,
  bool recursive = false,
}) async {
  deleteIfLink(file);
  final fileObject = File(file);
  if (recursive) {
    await fileObject.create(recursive: true);
  }
  await fileObject.writeAsString(contents, encoding: encoding);
}