writeToFileAsBytes function
Write to a file.
uri
is the URI of the file.bytes
is the content of the document as a list of bytesUint8List
.mode
is the mode in which the file will be opened for writing. UseFileMode.write
for truncating andFileMode.append
for appending to the file.
Returns true
if the file was successfully written to.
Implementation
Future<bool?> writeToFileAsBytes(
Uri uri, {
required Uint8List bytes,
FileMode? mode,
}) async {
final writeMode =
mode == FileMode.append || mode == FileMode.writeOnlyAppend ? 'wa' : 'wt';
final args = <String, dynamic>{
'uri': '$uri',
'content': bytes,
'mode': writeMode,
};
return kDocumentFileChannel.invokeMethod<bool>('writeToFile', args);
}