void writeAsStringSync(
String contents,
{FileMode mode: FileMode.WRITE,
Encoding encoding: UTF8,
bool flush: false}
)

Synchronously write a string to a file.

Opens the file, writes the string in the given encoding, and closes the file.

By default writeAsStringSync creates the file for writing and truncates the file if it already exists. In order to append the bytes to an existing file, pass FileMode.APPEND as the optional mode parameter.

If the flush argument is set to true data written will be flushed to the file system before returning.

Throws a FileSystemException if the operation fails.

Source

/**
 * Synchronously write a string to a file.
 *
 * Opens the file, writes the string in the given encoding, and closes the
 * file.
 *
 * By default [writeAsStringSync] creates the file for writing and
 * truncates the file if it already exists. In order to append the bytes
 * to an existing file, pass [FileMode.APPEND] as the optional mode
 * parameter.
 *
 * If the [flush] argument is set to `true` data written will be
 * flushed to the file system before returning.
 *
 * Throws a [FileSystemException] if the operation fails.
 */
void writeAsStringSync(String contents,
                       {FileMode mode: FileMode.WRITE,
                        Encoding encoding: UTF8,
                        bool flush: false});