write method

  1. @override
void write(
  1. String filePath,
  2. String content, {
  3. Warnable? element,
})
override

Writes content to a file at filePath.

If a file is to be overwritten, a warning will be reported on element.

Implementation

@override
void write(String filePath, String content, {Warnable? element}) {
  final bytes = utf8.encode(content);
  _validateMaxWriteStats(filePath, bytes.length);

  // Replace '/' separators with proper separators for the platform.
  var outFile = path.joinAll(filePath.split('/'));

  _warnAboutOverwrite(outFile, element);
  _fileElementMap[outFile] = element;

  var file = _getFile(outFile);
  file.writeAsBytesSync(bytes);
  writtenFiles.add(outFile);
  logProgress(outFile);
}