bmoni_embedded_wallets_cards 0.0.1
bmoni_embedded_wallets_cards: ^0.0.1 copied to clipboard
Embedded wallet and card building blocks for BKey apps: wallet read models, Riverpod notifiers, and composable wallet card widgets built on bkey_uikit.
bmoni_embedded_wallets_cards
Embedded wallet & card building blocks for Flutter apps in the BKey ecosystem β
wallet read models, Riverpod notifiers, and composable wallet card widgets
built on top of bkey_uikit.
β¨ Features #
- π§© Wallet-aware widgets β
EmbeddedWalletCardandEmbeddedWalletTransactionsSection, model-aware composites built onbkey_uikitprimitives. - π Pluggable contracts β bring your own data source, storage, and balance cache; the package depends only on small interfaces.
- β‘ Riverpod-ready notifiers β
EmbeddedWalletListNotifier,EmbeddedWalletBalanceNotifier, andEmbeddedWalletTransactionsNotifierwith built-in caching and offline fallback. - π‘οΈ Functional error handling β
Either<EmbeddedFailure, T>powered bydartzfor predictable success/failure paths. - π¨ Brand-coloured backgrounds β six per-currency colour variants
(
01β06) plus a default, all driven by yourEmbeddedWalletmodel. - π§ͺ Host-friendly β no routing, no l10n, no analytics; you own the app layer, this package owns the wallet/card composition.
π¦ Installation #
flutter pub add bmoni_embedded_wallets_cards
β¦or add it manually to your pubspec.yaml:
dependencies:
bmoni_embedded_wallets_cards: ^0.0.1
Then fetch packages:
flutter pub get
π Quick start #
import 'package:bmoni_embedded_wallets_cards/bmoni_embedded_wallets_cards.dart';
Wire a notifier with your own data source and storage, then render the card:
final notifier = EmbeddedWalletListNotifier(
walletDataSource: walletReadDataSource,
storage: walletStorage,
);
await notifier.fetchWallets();
EmbeddedWalletCard(
wallet: notifier.state.wallets!.first,
isBalanceHidden: false,
onToggleHideBalance: () {/* toggle in your app state */},
);
π§± Where this package fits #
bmoni_embedded_wallets_cards sits between your design system and your app:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Host app Β· routing Β· l10n Β· analytics Β· auth β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β bmoni_embedded_wallets_cards β
β Β· wallet/card-aware models β
β Β· Riverpod notifiers β
β Β· composed widgets β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β bkey_uikit Β· design tokens Β· UI primitives β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
bkey_uikitowns presentational primitives likeBMoniWalletCard,BMoniWalletCardBalance, andBMoniWalletCardBackgroundβ they accept already-resolved data and callbacks.bmoni_embedded_wallets_cardsowns the model-aware adapters that take anEmbeddedWalletand forward to those primitives with the right background, currency formatting, and balance state.- The host app stays in control of state β pass
isBalanceHidden/onToggleHideBalanceto wire the card into your own Riverpod or Bloc layer.
π Usage #
Wallet read data and state #
final EmbeddedWalletListNotifier notifier = EmbeddedWalletListNotifier(
walletDataSource: walletReadDataSource,
storage: walletStorage,
);
await notifier.fetchWallets();
if (notifier.state.hasError) {
// notifier.state.failure is an EmbeddedFailure
}
Embedded wallet card #
EmbeddedWalletCard(
wallet: embeddedWallet,
// Pick a colour variant (01β06) to use the brand-coloured background art,
// or omit to use the default per-currency background.
colorSuffix: '04',
// Wire to your own state management.
isBalanceHidden: hiddenBalances.contains(embeddedWallet.walletId),
onToggleHideBalance: () => toggleHidden(embeddedWallet.walletId),
isLoading: isInitialLoad,
isRefreshing: isPullToRefreshing,
onInfoTap: () => openWalletDetails(embeddedWallet),
onTap: () => openWalletDetails(embeddedWallet),
// Optional: override the prefix shown before the balance.
currencySymbol: r'$',
// Optional: override the entire whole-part formatting.
formatWholePart: (balance) => formatMyMoney(balance),
)
Embedded transactions section #
EmbeddedWalletTransactionsSection(
title: 'Recent transactions',
viewAllLabel: 'View all',
onViewAll: () => openTransactionsHistory(),
transactions: transactions,
emptyState: const SizedBox.shrink(),
itemBuilder: (context, transaction) {
return Text(transaction.id);
},
)
The widget intentionally leaves these responsibilities to the host app:
- what an empty state looks like
- how each transaction row is rendered
- what happens on View all
π§° Public API #
A single barrel import exposes everything:
import 'package:bmoni_embedded_wallets_cards/bmoni_embedded_wallets_cards.dart';
| Category | Exports |
|---|---|
| Constants | EmbeddedWalletCacheKeys |
| Contracts | EmbeddedWalletReadDataSource, EmbeddedWalletStorage, EmbeddedWalletBalanceCache |
| Failures | EmbeddedFailure, EmbeddedServerFailure, EmbeddedCacheFailure, EmbeddedNetworkFailure, EmbeddedValidationFailure, EmbeddedRateLimitFailure, EmbeddedNotFoundFailure, EmbeddedAuthenticationFailure, EmbeddedAuthorizationFailure |
| Models | EmbeddedWallet, EmbeddedWalletListResponse, EmbeddedWalletDetailResponse, EmbeddedWalletBalanceResponse, EmbeddedWalletTransactionsResponse, EmbeddedWalletTransaction, EmbeddedTransactionDirection, EmbeddedWalletTransactionStatus |
| Notifiers | EmbeddedWalletListNotifier, EmbeddedWalletBalanceNotifier, EmbeddedWalletTransactionsNotifier |
| Widgets | EmbeddedWalletCard, EmbeddedWalletTransactionsSection |
π§ͺ Example app #
A runnable, end-to-end example app lives in the example/
directory. It wires this package's notifiers into a Riverpod-based screen
with:
- a swipable
EmbeddedWalletCardcarousel with hide/show balance - an
EmbeddedWalletTransactionsSectionthat follows the active wallet - pull-to-refresh fanning out to the list, balance, and transaction notifiers
- in-memory implementations of
EmbeddedWalletReadDataSource,EmbeddedWalletStorage, andEmbeddedWalletBalanceCacheso it runs without a backend
cd example
flutter pub get
flutter run
See example/README.md for a tour of the wiring.
π§ Design rules #
- Keep domain-aware composition here, not in
bkey_uikit. - Keep host concerns out of this package: no
GoRouter, no app l10n, no app analytics services. - Prefer constructor-injected contracts over direct
getItor app service lookups. - Reuse
bkey_uikitprimitives instead of rebuilding generic layout or typography widgets.
π οΈ Development #
Run tests:
flutter test
Regenerate JSON code after model changes:
dart run build_runner build --delete-conflicting-outputs
π€ Contributing #
Issues and PRs are welcome on
GitHub.
Please run flutter test and flutter analyze before opening a PR.
π License #
Copyright Β© 2026 Bkey, Inc.
Licensed under the Apache License, Version 2.0 β you may use,
modify, and distribute this package (including in proprietary
applications) provided you preserve the copyright and license notices
and comply with the terms in the LICENSE file.
For commercial support or enterprise inquiries, contact developers@bkey.me.