createFileAsBytes function

Future<DocumentFile?> createFileAsBytes(
  1. Uri parentUri, {
  2. required String mimeType,
  3. required String displayName,
  4. required Uint8List bytes,
})

Create a direct child document of parentUri.

  • mimeType is the type of document following this specs.
  • displayName is the name of the document, must be a valid file name.
  • bytes is the content of the document as a list of bytes Uint8List.

Returns the created file as a DocumentFile.

Mirror of DocumentFile.createFile

Implementation

Future<DocumentFile?> createFileAsBytes(
  Uri parentUri, {
  required String mimeType,
  required String displayName,
  required Uint8List bytes,
}) async {
  final directoryUri = '$parentUri';

  final args = <String, dynamic>{
    'mimeType': mimeType,
    'content': bytes,
    'displayName': displayName,
    'directoryUri': directoryUri,
  };

  return invokeMapMethod('createFile', args);
}