saveFileWithDialog method

Future<String?> saveFileWithDialog(
  1. SaveFileDialogParams argParams
)

Save file through standard file saving dialog

But you should consider:

  1. For using this method you shouldn't specify android.permission.WRITE_EXTERNAL_STORAGE (only android)
  2. On Android if your phone can't handle Intent.ACTION_CREATE_DOCUMENT (e.g. devices with api 30 or higher) you will receive an exception with code NoResolvedActivityException

Implementation

Future<String?> saveFileWithDialog(SaveFileDialogParams argParams) async {
  final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
    'dev.flutter.pigeon.FileSaverApi.saveFileWithDialog',
    codec,
    binaryMessenger: _binaryMessenger,
  );
  final Map<Object?, Object?>? replyMap =
      await channel.send(<Object?>[argParams]) 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?);
  }
}