Skip to main content

Function Signature

Future<void> setPassword(String password)

Description

Sets the password to be used for password-based backup and recovery operations. This should be called before using backupWallet or recoverWallet with the password method.
The backupWallet and recoverWallet methods automatically call setPassword if a password is provided, so you typically don’t need to call this directly.

Parameters

ParameterTypeRequiredDescription
passwordStringYesThe password to set

Returns

void

Example

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Set password explicitly
await portal.setPassword('user-password');

// Then backup with password method
final response = await portal.backupWallet(
  method: PortalBackupMethod.password,
);

Typical Usage

Most commonly, you’ll pass the password directly to the backup/recovery methods:
// Password is set automatically
final response = await portal.backupWallet(
  method: PortalBackupMethod.password,
  password: 'user-password', // setPassword is called internally
);

Errors

CodeDescription
NOT_INITIALIZEDPortal was not initialized
INVALID_PASSWORDThe password is invalid (e.g., empty)