> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crossmint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CrossmintWalletStateRepository

> Flutter Final Class

**Final Class**

Single source of truth for the wallet state surfaced by `CrossmintWalletController` and the wallet provider UI layer. Holds the currently-loaded wallet, its identifier, and the lifecycle status; emits `notifyListeners()` whenever any of those change.

```dart theme={null}
final class CrossmintWalletStateRepository extends ChangeNotifier implements CrossmintWalletStateView
```

This class is deliberately small and side-effect-free: it does not fetch
wallets, call the transport layer, or touch the Crossmint API. The wallet
controller is responsible for orchestrating the API calls and pushing
results into this repository via `beginOperation`, `setWallet`,
`setError`, and `clear`.

Funnelling mutations through this type gives the SDK a clean seam to add
caching, optimistic updates, or offline persistence in the future without
touching the controller's public API.

## Constructors

### CrossmintWalletStateRepository

```dart theme={null}
CrossmintWalletStateRepository()
```

## Properties

### currentWallet

```dart theme={null}
CrossmintWallet? get currentWallet
```

### currentWalletId

```dart theme={null}
String? get currentWalletId
```

### status

```dart theme={null}
CrossmintWalletStatus get status
```

## Methods

### beginOperation

```dart theme={null}
void beginOperation()
```

Mark the beginning of a wallet operation (load / create / refresh). Transitions to `CrossmintWalletStatus.inProgress` without touching the stored wallet or wallet id, so consumers can still render stale data while a refresh runs. No-op if already in progress.

### setWallet

```dart theme={null}
void setWallet(CrossmintWallet? wallet)
```

Commit the result of a successful wallet operation. A non-null `wallet` transitions to `CrossmintWalletStatus.loaded`; a `null` wallet transitions to `CrossmintWalletStatus.notLoaded` and clears the stored id (mirroring the pre-repository controller contract — an explicit backend "not found" must not silently revive the previous wallet on the next `refresh()`).

### setError

```dart theme={null}
void setError()
```

Transition to `CrossmintWalletStatus.error` after a failed operation. The previously-loaded wallet and wallet id are preserved so consumers can still show stale data alongside the error.

### clear

```dart theme={null}
void clear()
```

Reset to the initial state. Transitions to `CrossmintWalletStatus.notLoaded` and clears both the wallet and its identifier.
