Skip to content
Flutter SDK

Flutter widgets

Optional, unbranded, accessible widgets built on the headless AppCore SDK.

On this page
Dart
import 'package:appcore_sdk/widgets.dart';

These widgets are optional and unbranded. They use Material widgets and read colours and text styles from your Theme. Each one is a thin layer over a headless API you can call directly instead.

Status: test/widgets_test.dart covers the purchase copy, the permission labels, the PurchaseStatusBanner live region, and the banner at 200% text scale. The other widgets have no widget tests, and no screen-reader run has been done. WS10 was still changing the widget copy on 2026-11-30, so check the source for the exact text.

EntitlementGate

Shows child when the feature is allowed for display, otherwise locked. When the snapshot is stale or in offlineGrace, it shows a short live-region notice above child (turn this off with staleBadge: false).

Dart
EntitlementGate(
  entitlements: core.entitlements,
  featureKey: '<entitlement-key>',
  online: isOnline,
  loading: const CircularProgressIndicator(),
  locked: const PaywallTeaser(),
  child: const PremiumLessons(),
)

Display only. The protected action itself must still call core.entitlements.requireLive(key). See Entitlements.

OtpSignInForm

A two-step email or WhatsApp OTP form: destination, then a 6-digit code. It shows the masked destination and how long the code stays valid (from expires_at), a resend countdown (from resend_after), and "Change". The challenge is kept across rebuilds. If delivery_status is unavailable, it tells the user to try another method.

Dart
OtpSignInForm(
  auth: core.auth,
  method: 'email_otp', // or 'whatsapp_otp'
  onSignedIn: (AuthResult r) => goHome(),
  onProblem: (AppCoreProblem p) => showProblem(p),
)

The copy is English and fixed. Build your own form on AuthClient if you need other text or localization. See Authentication.

NotificationPermissionCard

A contextual pre-permission card. It appears only when messaging.shouldOfferPermissionCard() is true, so it never shows on every launch. The OS prompt appears only after the user taps "Enable notifications". "Not now" is remembered.

Dart
NotificationPermissionCard(
  messaging: core.messaging,
  title: 'Get lesson reminders',
  benefit: 'We will remind you when your next lesson is ready.',
  onResult: (PushPermission p) => setState(() => permission = p),
)

pushPermissionLabel(PushPermission) returns a label for each OS permission state, for a settings row.

PurchaseStatusBanner

A live-region banner that announces the purchase stage. It shows a spinner while the stage is in progress. Only conflict gets error colours; failed and verificationDelayed do not. A store-sheet cancel shows nothing.

Dart
PurchaseStatusBanner(
  states: core.commerce.states,
  message: (s) => defaultPurchaseMessage(s, provider: Platform.isIOS ? 'apple' : 'google_play'),
)

Helpers:

  • defaultPurchaseMessage(PurchaseState, {String provider = 'apple'}) returns consumer copy for every PurchaseStage. provider changes the pending copy: Play deferred payment ("Payment pending") reads differently from Apple Ask to Buy ("Waiting for approval").
  • purchaseInProgress(PurchaseState?) is true for creatingIntent, awaitingStore, verifying and restoring. Use it to disable the buy button.

The reference app builds complete screens (login, paywall, inbox, settings) in examples/flutter-reference/lib/screens/. They are app code you can copy, not SDK widgets.