arch-atlas

Balance Controller

balance/controllers/balance_controller.dart · Notifier<BalanceState>

domain

Overview

Notifier that loads balance + transactions in parallel and exposes loadTransactionDetails for the detail bottom sheet. clearError / clearDetail bool flags drive copyWith's null overrides.

User Flow

  1. build() schedules Future.microtask(loadAll); initial state is isLoading: true.
  2. loadAll: Future.wait([getBalance, getTransactions]); maps results into models.
  3. loadTransactionDetails: per-row tap → getTransactionDetails(id) → set selectedTransactionDetail.
  4. refresh re-invokes loadAll.

Cases & Edge Cases

  • Errors are unwrapped via replaceFirst('Exception: ', '') for a cleaner SnackBar message.
  • If only one of (balance, transactions) succeeds, the other slot stays null — UI handles partial state.
  • loadTransactionDetails clearDetail=true on entry so the bottom sheet can show a loader without flashing stale data.

Code References

  • lib/src/features/seller/balance/controllers/balance_controller.dart:60 // BalanceController
  • lib/src/features/seller/balance/controllers/balance_controller.dart:73 // loadAll
  • lib/src/features/seller/balance/controllers/balance_controller.dart:112 // loadTransactionDetails
  • lib/src/features/seller/balance/controllers/balance_controller.dart:146 // balanceControllerProvider

API Calls

Empty — fill this in later. Open the manifest and add content here.

Notes

Owns its StripeService instance directly — not provider-wrapped.