Overview
Turnkey’s Flutter SDK provides a straightforward way to create and manage embedded wallets in your Flutter application. You can create wallets, derive accounts, import wallets, and keep local UI state in sync with provider data. Before starting, review the concepts of Wallets and Wallet Accounts.Creating an embedded wallet
After the user authenticates (i.e., asession exists on TurnkeyProvider), you can create an embedded wallet and specify which accounts to create within it.
lib/widgets/create_wallet_button.dart
Listing and refreshing wallets
TurnkeyProvider.wallets contains all embedded wallets for the current sub-organization. It updates automatically when wallets change.
lib/widgets/wallet_list.dart
lib/widgets/refresh_wallets_button.dart
Creating wallet accounts (after wallet creation)
To add accounts to an existing wallet, use thecreateWalletAccounts method from the underlying client.
lib/widgets/add_account_button.dart
Importing wallets
You can import a wallet from a mnemonic using theimportWallet method and optionally specify accounts to pre-create.
lib/widgets/import_wallet_button.dart
Exporting wallets
You can export a wallet’s mnemonic using theexportWallet method. This method will automatically decrypt the mnemonic for you.
lib/widgets/export_wallet_button.dart