writeString function

Future<File> writeString(
  1. File file,
  2. String content, {
  3. Encoding encoding = utf8,
})

Write a string content. Does not fail

Implementation

Future<File> writeString(File file, String content,
    {Encoding encoding = utf8}) async {
  try {
    await file.writeAsString(content, flush: true, encoding: encoding);
  } catch (_) {
    await file.create(recursive: true);
    await file.writeAsString(content, flush: true, encoding: encoding);
  }
  return file;
}