Skip to main content

Function Signature

Future<PortalBackupResponse> backupWallet({
  required PortalBackupMethod method,
  String? password,
})

Description

Creates a backup of the user’s wallet using the specified backup method. The backup allows the user to recover their wallet on a new device.

Parameters

ParameterTypeRequiredDescription
methodPortalBackupMethodYesThe backup method to use
passwordStringNoRequired when using PortalBackupMethod.password

PortalBackupMethod

ValueDescription
passwordBackup using a user-provided password
googleDriveBackup to Google Drive
iCloudBackup to iCloud (iOS only)
passkeyBackup using passkey/WebAuthn

Returns

PortalBackupResponse - An object containing:
PropertyTypeDescription
cipherTextString?The encrypted backup data (for self-managed backups)
shareIdsList<String>?List of share identifiers

Example

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Backup with password
final response = await portal.backupWallet(
  method: PortalBackupMethod.password,
  password: 'user-password',
);

// Backup with Google Drive
await portal.configureGoogleStorage(clientId: 'your-client-id');
final gdriveResponse = await portal.backupWallet(
  method: PortalBackupMethod.googleDrive,
);

Errors

CodeDescription
NOT_INITIALIZEDPortal was not initialized
WALLET_NOT_FOUNDNo wallet exists to backup
BACKUP_FAILEDThe backup operation failed
PASSWORD_REQUIREDPassword method selected but no password provided