saveFile method
Silent saving file into:
- Downloads directory (only Android)
- Document folder (only IOS) - downloaded files will be showed in Files App on iOS
Parameters:
filePath- absolute source file path.destinationFileName- file name with extension (e.g. file.pdf)
Implementation
Future<String?> saveFile(
String argFilepath,
String? argDestinationfilename,
) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FileSaverApi.saveFile',
codec,
binaryMessenger: _binaryMessenger,
);
final Map<Object?, Object?>? replyMap =
await channel.send(<Object?>[argFilepath, argDestinationfilename])
as Map<Object?, Object?>?;
if (replyMap == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyMap['error'] != null) {
final Map<Object?, Object?> error =
(replyMap['error'] as Map<Object?, Object?>?)!;
throw PlatformException(
code: (error['code'] as String?)!,
message: error['message'] as String?,
details: error['details'],
);
} else {
return (replyMap['result'] as String?);
}
}