Skip to content
Get started
Menu
Get started

Register

Use this general-purpose Authentication block when the host owns account creation and decides whether email verification is required. The details step validates email and password locally, explains the password policy, links to the host’s policy, reports host failure and can continue to a verification code step without becoming an identity service.

Create account screen with email and password fields, password policy help, a terms and privacy link, Create account pinned at the bottom and Log in navigation.Create account screen with email and password fields, password policy help, a terms and privacy link, Create account pinned at the bottom and Log in navigation.
Register, light and dark
Create account screen with a danger banner saying the host could not create the account; the typed values remain editable.
Host failure remains recoverable
Verify your email screen asking for a six digit code, with Verify email and Resend code actions.
Host-required verification
Verify your email screen with a danger banner for a wrong code; correction and retry remain available.
Wrong code remains recoverable
Create account screen at 200 percent text with the policy copy, password help and pinned action reflowed.
200% text

From example/:

Terminal window
flutter run -d <device-id> -t lib/auth_blocks_demo.dart

Open Create account from Login. Use any valid email and a password such as notes123. In Email verification required, the synthetic host asks for the fixture code 248913; a wrong code fails safely and resend is host-owned. In Registration continues directly, a successful registration navigates Home. The demo is Annota-themed but is not Annota’s production authentication, policy or account system.

RegisterBlock is self-contained apart from the package. The host chooses RegisterBlockStep.details or .verification and supplies onSubmit, onVerify, onResendVerification, onLogin, onPolicy, busy and a safe errorText. The block never creates an account, sends email, stores secrets, writes a consent record or verifies a code itself.

UI Existing library surface
Phone and wide page layout, title navigation and pinned action PaymentFullPageView
Email and verification-code input PaymentTextField
Submit, verification and resend states PaymentButton
Host failure announcement PaymentBanner
Login and policy navigation PaymentLink

The password control is deliberately host code inside the copied file. The kit does not accept secrets or provide a password-input mode (D1a); the host owns secret input, credential handling, account policy, consent records, verification delivery and routing. Pair it with Login for the connected authentication flow.

Source: compositions/register_block.dart

Open this file on GitHub. Copy and adapt it in your host app.

import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter/services.dart';
import 'package:rakit_ui/rakit_ui.dart';
/// Details sent to the host when the registration form is valid.
@immutable
class RegisterSubmission {
const RegisterSubmission({required this.email, required this.password});
final String email;
final String password;
}
/// Registration steps chosen by the host.
enum RegisterBlockStep {
/// Email and password details.
details,
/// Host-required email verification before the account can continue.
verification,
}
/// Copyable host composition: email/password registration, policy help,
/// validation, host failure and an optional host-owned verification step.
///
/// The block never creates an account, stores secrets, sends email or verifies
/// a code. [onSubmit], [onVerify] and [onResendVerification] are host
/// boundaries; [onLogin], [onPolicy] and [step] are host-owned navigation and
/// state. [busy] and [errorText] describe the current host attempt.
class RegisterBlock extends StatefulWidget {
const RegisterBlock({
super.key,
required this.onSubmit,
required this.onVerify,
required this.onResendVerification,
required this.onLogin,
required this.onPolicy,
this.step = RegisterBlockStep.details,
this.initialEmail = '',
this.verificationEmail,
this.busy = false,
this.errorText,
});
final Future<void> Function(RegisterSubmission submission) onSubmit;
final Future<void> Function(String code) onVerify;
final Future<void> Function() onResendVerification;
final VoidCallback onLogin;
final VoidCallback onPolicy;
final RegisterBlockStep step;
final String initialEmail;
/// Address the host says received the code.
final String? verificationEmail;
final bool busy;
/// Safe host message for the current failed step.
final String? errorText;
@override
State<RegisterBlock> createState() => _RegisterBlockState();
}
class _RegisterBlockState extends State<RegisterBlock> {
final _detailsKey = GlobalKey<FormState>();
final _verificationKey = GlobalKey<FormState>();
late final TextEditingController _email;
late final TextEditingController _password;
final _code = TextEditingController();
@override
void initState() {
super.initState();
_email = TextEditingController(text: widget.initialEmail);
_password = TextEditingController();
}
@override
void dispose() {
_email.dispose();
_password.dispose();
_code.dispose();
super.dispose();
}
String? _validateEmail(String? value) {
final email = value?.trim() ?? '';
if (email.isEmpty) return 'Enter your email address.';
final valid = RegExp(r'^[^@\s]+@[^@\s]+\.[^@\s]+$').hasMatch(email);
return valid ? null : 'Enter a valid email address.';
}
String? _validatePassword(String? value) {
final password = value ?? '';
if (password.length < 8) return 'Use at least 8 characters.';
if (!RegExp(r'[A-Za-z]').hasMatch(password) ||
!RegExp(r'\d').hasMatch(password)) {
return 'Use at least one letter and one number.';
}
return null;
}
String? _validateCode(String? value) =>
RegExp(r'^\d{6}$').hasMatch(value ?? '')
? null
: 'Enter the 6-digit code.';
void _submitDetails() {
FocusScope.of(context).unfocus();
if (!(_detailsKey.currentState?.validate() ?? false)) return;
widget.onSubmit(
RegisterSubmission(email: _email.text.trim(), password: _password.text),
);
}
void _submitCode() {
FocusScope.of(context).unfocus();
if (!(_verificationKey.currentState?.validate() ?? false)) return;
widget.onVerify(_code.text.trim());
}
@override
Widget build(BuildContext context) {
final theme = PaymentTheme.of(context);
final type = PaymentType.of(context);
final verification = widget.step == RegisterBlockStep.verification;
final email = widget.verificationEmail ?? _email.text.trim();
return PaymentFullPageView(
title: verification ? 'Verify your email' : 'Create account',
pageLink: PaymentLink(
label: 'Log in',
onPressed: widget.busy ? null : widget.onLogin,
),
primaryAction: verification
? PaymentButton(
label: 'Verify email',
busy: widget.busy,
busyLabel: 'Verifying your email',
onPressed: widget.busy ? null : _submitCode,
)
: PaymentButton(
label: 'Create account',
busy: widget.busy,
busyLabel: 'Creating your account',
onPressed: widget.busy ? null : _submitDetails,
),
secondaryAction: verification
? PaymentButton(
label: 'Resend code',
variant: PaymentButtonVariant.quiet,
onPressed: widget.busy ? null : widget.onResendVerification,
)
: null,
child: verification
? Form(
key: _verificationKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: theme.space(PaymentSpace.group),
children: [
if (widget.errorText != null)
PaymentBanner(
tone: StatusTone.danger,
title: 'Couldn’t verify your email',
message: widget.errorText,
announce: true,
),
Text(
'Enter the 6-digit code the host sent to $email.',
style: type.body.copyWith(color: theme.textPrimary),
),
PaymentTextField(
label: 'Verification code',
controller: _code,
type: PaymentTextFieldType.number,
required: true,
enabled: !widget.busy,
validator: _validateCode,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(6),
],
textInputAction: TextInputAction.done,
onSubmitted: (_) => _submitCode(),
autofillHints: const [AutofillHints.oneTimeCode],
),
],
),
)
: Form(
key: _detailsKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: theme.space(PaymentSpace.group),
children: [
if (widget.errorText != null)
PaymentBanner(
tone: StatusTone.danger,
title: 'Couldn’t create your account',
message: widget.errorText,
announce: true,
),
PaymentTextField(
label: 'Email address',
controller: _email,
type: PaymentTextFieldType.email,
required: true,
enabled: !widget.busy,
validator: _validateEmail,
textInputAction: TextInputAction.next,
autofillHints: const [AutofillHints.email],
),
RegisterPasswordField(
label: 'Password',
controller: _password,
enabled: !widget.busy,
validator: _validatePassword,
description:
'Use at least 8 characters with a letter and a number.',
autofillHint: AutofillHints.newPassword,
textInputAction: TextInputAction.done,
onSubmitted: (_) => _submitDetails(),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: theme.space(PaymentSpace.inline),
children: [
Text(
'By continuing, you agree to the host’s terms and privacy policy. The host owns the policy, consent record and account decision.',
style: type.caption.copyWith(
color: theme.textSecondary,
),
),
PaymentLink(
label: 'Read terms and privacy policy',
variant: PaymentLinkVariant.secondary,
onPressed: widget.busy ? null : widget.onPolicy,
),
],
),
],
),
),
);
}
}
/// Host-owned password input. The kit deliberately has no secret-input mode;
/// a copied block keeps this control in host code.
class RegisterPasswordField extends StatefulWidget {
const RegisterPasswordField({
super.key,
required this.label,
required this.controller,
this.enabled = true,
this.validator,
this.errorText,
this.description,
this.autofillHint = AutofillHints.newPassword,
this.textInputAction,
this.onSubmitted,
});
final String label;
final TextEditingController controller;
final bool enabled;
final FormFieldValidator<String>? validator;
final String? errorText;
final String? description;
final String autofillHint;
final TextInputAction? textInputAction;
final ValueChanged<String>? onSubmitted;
@override
State<RegisterPasswordField> createState() => _RegisterPasswordFieldState();
}
class _RegisterPasswordFieldState extends State<RegisterPasswordField> {
bool _obscured = true;
@override
Widget build(BuildContext context) {
final theme = PaymentTheme.of(context);
final type = PaymentType.of(context);
final labelAbove = PaymentType.isLarge(context);
final border = OutlineInputBorder(
borderRadius: theme.controlBorderRadius,
borderSide: BorderSide(color: theme.border),
);
final errorBorder = OutlineInputBorder(
borderRadius: theme.controlBorderRadius,
borderSide: BorderSide(color: theme.danger.foreground),
);
return Semantics(
label: labelAbove ? widget.label : null,
isRequired: true,
validationResult: widget.errorText == null
? SemanticsValidationResult.none
: SemanticsValidationResult.invalid,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: theme.space(PaymentSpace.inline),
children: [
if (labelAbove)
ExcludeSemantics(
child: Text(
widget.label,
style: type.label.copyWith(
color: widget.enabled ? theme.textSecondary : theme.disabled,
),
),
),
TextFormField(
controller: widget.controller,
enabled: widget.enabled,
obscureText: _obscured,
autocorrect: false,
enableSuggestions: false,
keyboardType: TextInputType.visiblePassword,
autofillHints: [widget.autofillHint],
textInputAction: widget.textInputAction,
onFieldSubmitted: widget.onSubmitted,
validator: widget.validator,
forceErrorText: widget.errorText,
style: type.input.copyWith(
color: widget.enabled ? theme.textPrimary : theme.disabled,
),
decoration: InputDecoration(
labelText: labelAbove ? null : widget.label,
labelStyle: type.label.copyWith(
color: widget.enabled ? theme.textSecondary : theme.disabled,
),
filled: true,
fillColor: theme.surface,
contentPadding: labelAbove
? EdgeInsetsDirectional.symmetric(
horizontal: theme.space(PaymentSpace.group) - 4,
vertical: theme.space(PaymentSpace.group),
)
: EdgeInsetsDirectional.fromSTEB(
theme.space(PaymentSpace.group) - 4,
theme.space(PaymentSpace.group) +
theme.space(PaymentSpace.inline),
theme.space(PaymentSpace.group) - 4,
theme.space(PaymentSpace.block),
),
enabledBorder: border,
disabledBorder: border.copyWith(
borderSide: BorderSide(color: theme.outline),
),
focusedBorder: border.copyWith(
borderSide: BorderSide(color: theme.accent, width: 2),
),
errorBorder: errorBorder,
focusedErrorBorder: errorBorder.copyWith(
borderSide: BorderSide(
color: theme.danger.foreground,
width: 2,
),
),
errorStyle: type.caption.copyWith(color: theme.danger.foreground),
suffixIconConstraints: const BoxConstraints(
minWidth: 48,
minHeight: 48,
),
suffixIcon: PaymentIconButton(
icon: _obscured
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
tooltip: _obscured ? 'Show password' : 'Hide password',
onPressed: widget.enabled
? () => setState(() => _obscured = !_obscured)
: null,
),
),
),
if (widget.description != null)
Text(
widget.description!,
style: type.caption.copyWith(color: theme.textSecondary),
),
],
),
);
}
}
Source: auth_blocks_demo.dart

Open this file on GitHub. Copy and adapt it in your host app.

import 'package:flutter/material.dart';
import 'package:rakit_ui/rakit_ui.dart';
import 'block_demo_shell.dart';
import 'compositions/login_block.dart';
import 'compositions/register_block.dart';
void main() => runBlockDemo(const AuthBlocksDemo());
enum AuthDemoScenario {
signInFailsOnce,
registrationFailsOnce,
verificationRequired,
directAccount,
}
enum _Route { login, register, recovery, policy, home }
const _fixtureEmail = 'mina@example.com';
const _fixturePassword = 'notes123';
const _fixtureCode = '248913';
/// Synthetic Annota-themed host connecting the generic Login and Register
/// blocks. It is deliberately not Annota's production authentication flow:
/// there is no backend, account store, email delivery or secret persistence.
class AuthBlocksDemo extends StatefulWidget {
const AuthBlocksDemo({
super.key,
this.initialScenario = AuthDemoScenario.signInFailsOnce,
this.initialDark = false,
this.delay = const Duration(milliseconds: 600),
this.textScale,
this.initiallyRegister = false,
});
final AuthDemoScenario initialScenario;
final bool initialDark;
final Duration delay;
final bool initiallyRegister;
/// Optional fixed text scale for accessibility proof.
final double? textScale;
@override
State<AuthBlocksDemo> createState() => _AuthBlocksDemoState();
}
class _AuthBlocksDemoState extends State<AuthBlocksDemo> {
late bool dark = widget.initialDark;
late AuthDemoScenario scenario = widget.initialScenario;
late _Route route = widget.initiallyRegister ? _Route.register : _Route.login;
RegisterBlockStep registerStep = RegisterBlockStep.details;
String? loginError;
String? registerError;
String? recoveryMessage;
bool busy = false;
int generation = 0;
int signInAttempts = 0;
int registerAttempts = 0;
int recoveryVisits = 0;
String registeredEmail = _fixtureEmail;
void reset(AuthDemoScenario next) => setState(() {
generation++;
scenario = next;
route = _Route.login;
registerStep = RegisterBlockStep.details;
loginError = null;
registerError = null;
recoveryMessage = null;
busy = false;
signInAttempts = 0;
registerAttempts = 0;
recoveryVisits = 0;
registeredEmail = _fixtureEmail;
});
void open(_Route next) {
if (next != route) FocusScope.of(context).unfocus();
setState(() {
route = next;
loginError = null;
registerError = null;
if (next == _Route.recovery) {
recoveryVisits++;
recoveryMessage = null;
}
});
}
void abandonRegistration() {
FocusScope.of(context).unfocus();
setState(() {
route = _Route.login;
registerStep = RegisterBlockStep.details;
registerError = null;
registeredEmail = _fixtureEmail;
});
}
Future<void> signIn(LoginCredentials credentials) async {
if (busy) return;
final current = generation;
signInAttempts++;
setState(() {
busy = true;
loginError = null;
});
await Future<void>.delayed(widget.delay);
if (!mounted || current != generation) return;
setState(() {
busy = false;
final failFirst =
scenario == AuthDemoScenario.signInFailsOnce && signInAttempts == 1;
final wrongFixture =
credentials.email != _fixtureEmail ||
credentials.password != _fixturePassword;
if (failFirst || wrongFixture) {
loginError =
'Check the email and password for this synthetic account, then try again.';
return;
}
route = _Route.home;
});
}
Future<void> register(RegisterSubmission submission) async {
if (busy) return;
final current = generation;
registerAttempts++;
setState(() {
busy = true;
registerError = null;
registeredEmail = submission.email;
});
await Future<void>.delayed(widget.delay);
if (!mounted || current != generation) return;
setState(() {
busy = false;
if (scenario == AuthDemoScenario.registrationFailsOnce &&
registerAttempts == 1) {
registerError =
'The illustrative host could not create the account. Nothing was saved; try again.';
return;
}
if (scenario == AuthDemoScenario.verificationRequired) {
registerStep = RegisterBlockStep.verification;
} else {
route = _Route.home;
}
});
}
Future<void> verify(String code) async {
if (busy) return;
final current = generation;
setState(() {
busy = true;
registerError = null;
});
await Future<void>.delayed(widget.delay);
if (!mounted || current != generation) return;
setState(() {
busy = false;
if (code != _fixtureCode) {
registerError =
'That code does not match the synthetic message. Use $_fixtureCode or resend it.';
return;
}
route = _Route.home;
});
}
Future<void> resendCode() async {
if (busy) return;
final current = generation;
setState(() => busy = true);
await Future<void>.delayed(widget.delay);
if (!mounted || current != generation) return;
setState(() {
busy = false;
registerError = null;
});
}
Future<void> sendRecovery(String email) async {
if (busy) return;
final current = generation;
final visit = recoveryVisits;
setState(() {
busy = true;
recoveryMessage = null;
});
await Future<void>.delayed(widget.delay);
if (!mounted || current != generation) return;
final deliver = visit == recoveryVisits && route == _Route.recovery;
setState(() {
busy = false;
recoveryMessage = deliver
? 'If $email belongs to this synthetic host, a reset message is waiting in the fixture inbox.'
: null;
});
}
RegisterBlock _registerBlock() => RegisterBlock(
key: ValueKey('register-$generation-$registerStep'),
step: registerStep,
initialEmail: _fixtureEmail,
verificationEmail: registeredEmail,
busy: busy,
errorText: registerError,
onSubmit: register,
onVerify: verify,
onResendVerification: resendCode,
onLogin: abandonRegistration,
onPolicy: () => open(_Route.policy),
);
Widget _registerOrPolicy() {
final policy = route == _Route.policy;
return Stack(
fit: StackFit.expand,
children: [
ExcludeFocus(
excluding: policy,
child: ExcludeSemantics(
excluding: policy,
child: Offstage(offstage: policy, child: _registerBlock()),
),
),
if (policy) _PolicyPage(onBack: () => open(_Route.register)),
],
);
}
@override
Widget build(BuildContext context) => BlockDemoShell(
title: 'Annota auth · illustrative demo',
dark: dark,
onToggleDark: () => setState(() => dark = !dark),
lightTheme: annotaTheme(Brightness.light),
darkTheme: annotaTheme(Brightness.dark),
locale: const Locale('en'),
textScale: widget.textScale,
scenarios: [
(
label: 'Sign-in fails once',
onSelected: () => reset(AuthDemoScenario.signInFailsOnce),
),
(
label: 'Registration fails once',
onSelected: () => reset(AuthDemoScenario.registrationFailsOnce),
),
(
label: 'Email verification required',
onSelected: () => reset(AuthDemoScenario.verificationRequired),
),
(
label: 'Registration continues directly',
onSelected: () => reset(AuthDemoScenario.directAccount),
),
],
body: (context) => switch (route) {
_Route.login => LoginBlock(
key: ValueKey('login-$generation'),
initialEmail: _fixtureEmail,
busy: busy,
errorText: loginError,
onSubmit: signIn,
onForgotPassword: () => open(_Route.recovery),
onRegister: () => open(_Route.register),
),
_Route.register || _Route.policy => _registerOrPolicy(),
_Route.recovery => _RecoveryPage(
key: ValueKey('recovery-$generation-$recoveryVisits'),
busy: busy,
message: recoveryMessage,
initialEmail: _fixtureEmail,
onSubmit: sendRecovery,
onBack: () => open(_Route.login),
),
_Route.home => _HomePage(onSignOut: () => reset(scenario)),
},
);
}
class _RecoveryPage extends StatefulWidget {
const _RecoveryPage({
super.key,
required this.busy,
required this.message,
required this.initialEmail,
required this.onSubmit,
required this.onBack,
});
final bool busy;
final String? message;
final String initialEmail;
final Future<void> Function(String email) onSubmit;
final VoidCallback onBack;
@override
State<_RecoveryPage> createState() => _RecoveryPageState();
}
class _RecoveryPageState extends State<_RecoveryPage> {
final _formKey = GlobalKey<FormState>();
late final _email = TextEditingController(text: widget.initialEmail);
@override
void dispose() {
_email.dispose();
super.dispose();
}
void submit() {
if (!(_formKey.currentState?.validate() ?? false)) return;
widget.onSubmit(_email.text.trim());
}
@override
Widget build(BuildContext context) {
final theme = PaymentTheme.of(context);
return PaymentFullPageView(
title: 'Reset password',
pageLink: PaymentLink(label: 'Log in', onPressed: widget.onBack),
primaryAction: PaymentButton(
label: 'Send reset message',
busy: widget.busy,
busyLabel: 'Sending reset message',
onPressed: widget.busy ? null : submit,
),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: theme.space(PaymentSpace.group),
children: [
if (widget.message != null)
PaymentBanner(
tone: StatusTone.success,
title: 'Reset message recorded',
message: widget.message,
announce: true,
),
PaymentTextField(
label: 'Email address',
controller: _email,
type: PaymentTextFieldType.email,
required: true,
enabled: !widget.busy,
validator: (value) =>
RegExp(r'^[^@\s]+@[^@\s]+\.[^@\s]+$').hasMatch(value ?? '')
? null
: 'Enter a valid email address.',
textInputAction: TextInputAction.done,
onSubmitted: (_) => submit(),
),
],
),
),
);
}
}
class _PolicyPage extends StatelessWidget {
const _PolicyPage({required this.onBack});
final VoidCallback onBack;
@override
Widget build(BuildContext context) {
final theme = PaymentTheme.of(context);
final type = PaymentType.of(context);
return PaymentFullPageView(
title: 'Terms and privacy',
pageLink: PaymentLink(label: 'Create account', onPressed: onBack),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: theme.space(PaymentSpace.group),
children: [
const PaymentBanner(
tone: StatusTone.neutral,
title: 'Illustrative host policy',
message:
'This page belongs to the demo host. It is not Annota production policy or authentication copy.',
),
Text(
'In a real app, this destination explains what account data the host collects, why it collects it, retention, deletion and contact choices. The block only opens the host destination; it never writes a consent record.',
style: type.body.copyWith(color: theme.textPrimary),
),
],
),
);
}
}
class _HomePage extends StatelessWidget {
const _HomePage({required this.onSignOut});
final VoidCallback onSignOut;
@override
Widget build(BuildContext context) {
final theme = PaymentTheme.of(context);
final type = PaymentType.of(context);
return PaymentFullPageView(
title: 'Home',
primaryAction: PaymentButton(
label: 'Sign out',
variant: PaymentButtonVariant.secondary,
onPressed: onSignOut,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: theme.space(PaymentSpace.group),
children: [
const PaymentBanner(
tone: StatusTone.success,
title: 'Signed in',
message:
'The host navigated here after its synthetic authentication callback.',
),
const PaymentBanner(
tone: StatusTone.neutral,
title: 'Illustrative Annota host',
message:
'This is a synthetic auth demo, not Annota’s production sign-in or account system.',
),
PaymentSection(
title: 'Next in Annota',
child: Text(
'Scan a document, review highlights and save notes. Those product surfaces are outside this authentication block demo.',
style: type.body.copyWith(color: theme.textPrimary),
),
),
],
),
);
}
}
/// Annota-derived illustrative host theme. Light colors follow the pinned web
/// handoff; the dark adaptation exists only so the demo can inspect kit states
/// in both appearances and is not an Annota production dark palette.
ThemeData annotaTheme(Brightness brightness) {
final dark = brightness == Brightness.dark;
final ink = dark ? const Color(0xFFF8FAFC) : const Color(0xFF0F172B);
final surface = dark ? const Color(0xFF0F172B) : Colors.white;
final muted = dark ? const Color(0xFF1E293B) : const Color(0xFFF8FAFC);
final secondary = dark ? const Color(0xFFCBD5E1) : const Color(0xFF62748E);
final border = dark ? const Color(0xFF94A3B8) : const Color(0xFF94A3B8);
final onAccent = dark ? const Color(0xFF0F172B) : Colors.white;
final scheme = ColorScheme.fromSeed(
seedColor: const Color(0xFF0F172B),
brightness: brightness,
primary: ink,
onPrimary: onAccent,
surface: surface,
onSurface: ink,
);
final payment = PaymentTheme.fromColorScheme(scheme).copyWith(
accent: ink,
onAccent: onAccent,
surface: surface,
surfaceMuted: muted,
outline: dark ? const Color(0xFF334155) : const Color(0xFFF1F5F9),
textPrimary: ink,
textSecondary: secondary,
border: border,
disabled: dark ? const Color(0xFF64748B) : const Color(0xFFA3AAB8),
radius: 12,
controlRadius: 6,
);
return ThemeData(
colorScheme: scheme,
useMaterial3: true,
scaffoldBackgroundColor: surface,
extensions: [payment],
dividerTheme: DividerThemeData(color: payment.outline, space: 1),
appBarTheme: AppBarTheme(
backgroundColor: surface,
foregroundColor: ink,
surfaceTintColor: Colors.transparent,
scrolledUnderElevation: 0,
centerTitle: false,
titleTextStyle: TextStyle(
fontSize: 17,
height: 24 / 17,
fontWeight: FontWeight.w600,
color: ink,
),
shape: Border(bottom: BorderSide(color: payment.outline)),
),
popupMenuTheme: PopupMenuThemeData(
color: surface,
surfaceTintColor: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: payment.controlBorderRadius,
side: BorderSide(color: payment.outline),
),
),
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: surface,
border: OutlineInputBorder(
borderRadius: payment.controlBorderRadius,
borderSide: BorderSide(color: border),
),
),
);
}
Source: block_demo_shell.dart

Open this file on GitHub. Copy and adapt it in your host app.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:rakit_ui/rakit_ui.dart';
import 'themes.dart';
/// Starts a block demo edge-to-edge, as the shipped checkout demo does.
void runBlockDemo(Widget app) {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
runApp(app);
}
/// The example host's clipboard effect. It reports the real outcome and never
/// claims a copy that did not happen. The kit itself never touches the
/// clipboard (B11).
Future<bool> copyToClipboard(String value) async {
try {
await Clipboard.setData(ClipboardData(text: value));
return true;
} on PlatformException {
return false;
}
}
/// One developer scenario in the demo menu. Choosing it restarts the
/// synthetic session; it is never an end-user action.
typedef DemoScenario = ({String label, VoidCallback onSelected});
/// Ordinary phone host chrome shared by the block demos: app themes, Indonesian
/// localization, D85 system-bar styling, a light/dark switch and a developer
/// scenario menu. It is example scaffolding, not a block runtime: copy the
/// composition under `compositions/` and keep your own app shell.
class BlockDemoShell extends StatelessWidget {
const BlockDemoShell({
super.key,
required this.title,
required this.dark,
required this.onToggleDark,
required this.body,
this.scenarios = const [],
this.lightTheme,
this.darkTheme,
this.locale = const Locale('id'),
this.textScale,
});
final String title;
final bool dark;
final VoidCallback onToggleDark;
final List<DemoScenario> scenarios;
/// Optional illustrative host themes; the payment demos use Ruang Bayar.
final ThemeData? lightTheme;
final ThemeData? darkTheme;
/// Host locale for this synthetic demo.
final Locale locale;
/// Optional fixed text scale for accessibility captures; null follows the
/// device setting.
final double? textScale;
/// Built below the Scaffold, so sheets and toasts find their ancestors.
final WidgetBuilder body;
@override
Widget build(BuildContext context) => MaterialApp(
debugShowCheckedModeBanner: false,
theme: lightTheme ?? buildTheme(DemoBrand.ruangBayar, Brightness.light),
darkTheme: darkTheme ?? buildTheme(DemoBrand.ruangBayar, Brightness.dark),
themeMode: dark ? ThemeMode.dark : ThemeMode.light,
locale: locale,
supportedLocales: const [Locale('id'), Locale('en')],
localizationsDelegates: const [
PaymentLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
builder: (context, child) {
final scale = textScale;
if (scale == null) return child!;
return MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(scale)),
child: child!,
);
},
home: AnnotatedRegion<SystemUiOverlayStyle>(
// D85: the host styles the system bars from its resolved theme.
value: (dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark)
.copyWith(
systemNavigationBarColor: Colors.transparent,
systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarContrastEnforced: false,
),
child: Scaffold(
appBar: AppBar(
title: Text(title),
actions: [
PaymentIconButton(
icon: dark ? Icons.light_mode_outlined : Icons.dark_mode_outlined,
tooltip: dark ? 'Mode terang' : 'Mode gelap',
onPressed: onToggleDark,
),
if (scenarios.isNotEmpty)
PopupMenuButton<int>(
tooltip: 'Skenario demo',
onSelected: (i) => scenarios[i].onSelected(),
itemBuilder: (_) => [
for (final (i, s) in scenarios.indexed)
PopupMenuItem(value: i, child: Text(s.label)),
],
),
],
),
body: SafeArea(top: false, child: Builder(builder: body)),
),
),
);
}

Widget tests cover password policy validation, host failure and retry, policy navigation, host-required verification, wrong-code recovery, and the connected home destination. Android captures cover light, dark, failure, verification and enlarged text. Connect your own account backend, verification service, consent records, abuse controls and navigation before production use.