Skip to content
Get started
Menu
Get started

Host-owned decisions

Your app and backend determine payment results. A request timeout means the client has no answer yet; it does not establish payment failure. The kit displays the data you supply and reports user actions through callbacks.

The data flow is always the same:

provider response → your adapter (parses, validates) → kit models → widgets

Widgets never trust raw JSON. Your adapter maps unknown values to a safe “unavailable” state instead of inventing a transaction result.

Area Owner What the kit does
Input value, focus, expanded details Widget Interaction and presentation-level validation
Identity requirements, consent policy, payment permission Host/backend Shows the policy it is given; sets no universal rule
Document upload and KYC decision Host adapter/backend Shows progress, structured errors and the result
Price, fees, limits, quote expiry Host/backend Renders the full snapshot; asks for re-approval when it changes
Authorization challenge and credentials Host auth SDK/backend Shows the state and delegates the action; no raw PIN/OTP in public models
Payment status, idempotency, refund Host/backend/provider Renders authoritative state; does not claim the UI alone prevents a double charge
Async search Host state/coordinator Receives query intent; host fetches options, owns loading/errors, rejects stale responses and decides retry policy
Settings persistence Host store/backend Renders supplied values and reports edits/Save; host persists them and handles failure
Validation Host form/backend Shows supplied errors and runs supplied validators; host defines business rules and server validation
Navigation from sheets Host router Presents/dismisses the surface; host closes it and routes using the appropriate navigator
Status polling, recovery, lifecycle Host coordinator Offers events and callbacks; widgets start no hidden polling

Your app also controls Android system-bar styling. See System bars on Android.

Pass these results from your app or backend:

  • BalanceCard takes a BalanceState (sufficient, insufficient, unavailable) and an optional shortfall. It never compares the balance with the total.
  • PromoCodeInput takes a PromoCodeStatus (idle, checking, applied, rejected). A discount reaches the total only as a new host quote with a QuoteLineKind.discount line.
  • PaymentSummary renders PaymentQuote.total as given. It never adds the lines up.
  • PaymentStatusView shows a status only from a PaymentStatusSnapshot you produced; it never infers success.
  • VerificationStatusView shows verified only when your snapshot says so, never because an upload finished.

Layout: the height you give opts into the pinned action

Section titled “Layout: the height you give opts into the pinned action”

Your app also controls screen layout. PaymentConfirmation, AuthorizationPrompt, PaymentStatusView, VerificationIntro and VerificationStatusView adapt to the height constraints you provide:

  • Bounded (a Scaffold body, an Expanded, a SizedBox): the content scrolls and the priority action pins to a footer at the bottom, inside the safe area, with at most one quiet action under it.
  • Unbounded (inside your ListView or SingleChildScrollView): the actions follow the content.

Put a banner or summary that belongs above the widget in its header, so it scrolls with the content; wrapping both in a Column makes the height unbounded. In a payment flow, hide your app’s tab bar so the pinned action is the only thing at the bottom. If you already gave one of these widgets a bounded height and want the old inline layout, put it in a scroll view.

Your adapter maps provider failures into a HostError with a HostErrorCategory (network, timeout, validation, sessionExpired, notAllowed, conflict, invalidResponse, unavailable, unknown) and an optional safeMessage you approved for end users. Raw exceptions and provider payloads never reach the widgets.

timeout is its own category on purpose: the request was sent but no answer arrived, so its outcome is unknown. See Payment attempt and status.

const HostError(
HostErrorCategory.network,
safeMessage: 'Check your connection and try again.',
);

retryable defaults to true; set it to false when trying again cannot help. outcomeUnknown is true for timeout, and callers must not treat those errors as failures.

HostError

class HostError · lib/src/foundation/host_error.dart

ParameterTypeDefaultDescription
categoryrequiredpositionalHostErrorCategory——
safeMessage:String?—Copy approved by the host for end users, or null to use the default.
retryable:booltrue—

HostErrorCategory

enum HostErrorCategory · lib/src/foundation/host_error.dart

Structured error categories a host adapter maps provider failures into.

Raw exceptions and provider payloads never reach widgets; only a category and an optional message the host has decided is safe to show.

ValueDescription
networkThe request may not have reached the server.
timeoutThe request was sent but no answer arrived; its outcome is unknown.
validation—
sessionExpired—
notAllowed—
conflict—
invalidResponseThe server answered with data the adapter could not trust.
unavailable—
unknown—

The package does not pick a state manager, router, camera, media engine or payment provider for you. Its only dependency is the Flutter SDK. The example app uses a plain Dart coordinator (example/lib/coordinator/demo_coordinator.dart) as the single owner of payment state, and a fake host (example/lib/adapters/fake_host.dart) that simulates the backend, provider, idempotency and device capabilities.

The fake host proves the UI and coordinator contract against a fake host only, not against a real provider.

  • Demo identities, documents, payment references and money are synthetic.
  • Status and error models carry no raw provider payload. Identity data is shown only as far as review needs it.
  • The core package makes no network calls and has no analytics.
  • Your host owns auth and sessions, authorization of each transaction, server-side upload validation, idempotency, rate limits, and document retention and deletion.
  • PrivacyMask hides sensitive content (for example in the app switcher). Platform screenshot protection is your app’s responsibility.
  • Sharing a receipt passes only allowlisted fields (ReceiptShareData), never a screenshot of KYC pages or app state.