W3cubDocs

/Dart 2

writeAsBytes method

Future<File> writeAsBytes (List<int> bytes, { FileMode mode: FileMode.write, bool flush: false })

Write a list of bytes to a file.

Opens the file, writes the list of bytes to it, and closes the file. Returns a Future<File> that completes with this File object once the entire operation has completed.

By default writeAsBytes 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 argument flush is set to true, the data written will be flushed to the file system before the returned future completes.

Implementation

Future<File> writeAsBytes(List<int> bytes,
    {FileMode mode: FileMode.write, bool flush: false});

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-io/File/writeAsBytes.html