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
| Parameter | Type | Required | Description |
|---|
password | String | Yes | The 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
| Code | Description |
|---|
NOT_INITIALIZED | Portal was not initialized |
INVALID_PASSWORD | The password is invalid (e.g., empty) |