createUri static method

Future<String?> createUri(
  1. String fileName, {
  2. String? childDirectoryName,
  3. String mimeType = 'application/pdf',
})

This method is supported only on the Android platform. It is used to create a URI for saving a file on the Android device. The file is saved in the Downloads directory by default, but you can specify a subdirectory within Downloads using the childDirectoryName parameter. If the childDirectoryName is not provided, the file will be saved directly in the Downloads directory. The fileName parameter is required to specify the name of the file (e.g., test.pdf).

Example usage:

String? uri = await ComPDFKit.createUri('test.pdf');
  • fileName (required) specifies the name of the file, for example test.pdf.
  • childDirectoryName (optional) specifies a subdirectory within the Downloads folder.
  • mimeType (optional) is the MIME type of the file, defaulting to application/pdf.

Implementation

static Future<String?> createUri(String fileName,
    {String? childDirectoryName, String mimeType = 'application/pdf'}) async {
  final String? uri = await _methodChannel.invokeMethod('create_uri', {
    'file_name': fileName,
    'child_directory_name': childDirectoryName,
    'mime_type': mimeType
  });
  return uri;
}