writeToFileSync method

void writeToFileSync(
  1. String filePath
)

Implementation

void writeToFileSync(String filePath) {
  final file = File(filePath);
  try {
    if (file.existsSync())
      file.deleteSync(); // Ensure we flush the file to 0 bytes
  } catch (E) {
    // If it fails then it fails, just fail silently, writing should still succeed.
  }

  var rac = file.openSync(mode: FileMode.write);

  for (var byte in bytes) {
    rac.writeByteSync(byte);
  }

  rac.flushSync();
  rac.closeSync();
}