writeString static method

void writeString(
  1. String path,
  2. String content
)

Writes a string to a file, creating parent folders if necessary.

Implementation

static void writeString(String path, String content) {
  try {
    final file = File(path);
    final dir = Directory(PathUtils.dirname(path));
    if (!dir.existsSync()) {
      dir.createSync(recursive: true);
    }
    file.writeAsStringSync(content);
  } catch (e) {
    throw DeepLinkException('Failed to write file $path', e);
  }
}