Text field
PaymentTextField is a labeled single-line input. Your app handles values, validation and submission.







Minimal
Section titled “Minimal”Add the published package, then paste this complete example into lib/main.dart.
import 'package:flutter/material.dart';import 'package:rakit_ui/rakit_ui.dart';
void main() => runApp(const MaterialApp(home: NamePage()));
class NamePage extends StatefulWidget { const NamePage({super.key}); @override State<NamePage> createState() => _NamePageState();}
class _NamePageState extends State<NamePage> { String name = ''; @override Widget build(BuildContext context) => Scaffold( appBar: AppBar(title: const Text('Example')), body: ListView( padding: const EdgeInsets.all(16), children: [ PaymentTextField( label: 'Name', onChanged: (value) => setState(() => name = value), ), Text('Hello, $name'), ], ), );}Behavior
Section titled “Behavior”There is no autofocus: touch keyboards open only when you request focus through a focusNode. Use input formatters for length constraints and validators for meaning. keyboardType keeps custom keyboards, including dates.
Variants
Section titled “Variants”Variants: text, number, tel, url, email, search; small, medium, large.
Which variant
Section titled “Which variant”Use a general field for names and addresses, reference typography for identifiers, a currency field for money parsing, and .search for immediate local filtering. Remote search debounce belongs to the host.
Variants: type × size, reference, .search.
Content and accessibility
Section titled “Content and accessibility”Keep a persistent label. Never put the only instruction in hint. Explain how to fix an error. Every size uses 16 px input text; padding varies without shrinking text. Hidden labels, descriptions and errors remain spoken. Required is semantic; the host must enforce it. Clearing search reports an empty query and refocuses the field. .search(actions: …) puts filter controls, such as a calendar PaymentIconButton, after the box on the same line, centred on the box; at large text the label above spans them. .search(hiddenElements: {PaymentFieldPart.label}) shows the label as the placeholder instead, and the label stays the field’s spoken name (TransactionHistory does this when it has searchActions, D63a).
PaymentTextField
class PaymentTextField extends StatefulWidget · lib/src/controls/text_field.dart
Labeled single-line input integrated with Form validation.
| Parameter | Type | Default | Description |
|---|---|---|---|
label:required | String | — | Always visible; floats above the value, or sits above the box and wraps when text is scaled above 1.5×. |
controller: | TextEditingController? | — | Host-owned editing controller. |
initialValue: | String? | — | Starting value when no controller is supplied. |
focusNode: | FocusNode? | — | Host focus node; otherwise owned internally. |
hint: | String? | — | Supplemental hint; never the only instruction. |
description: | String? | — | Caption beneath the field. |
descriptionTone: | StatusTone | StatusTone.neutral | Optional semantic tone for the description. |
errorText: | String? | — | Host error; hides on edit. Pass null between identical attempts. |
validator: | FormFieldValidator<String>? | — | Form validation; errors include an icon. |
required: | bool | false | Spoken as required; enforced by the host validator. |
hiddenElements: | Set<PaymentFieldPart> | const {} | Hidden parts remain in semantics. |
type: | PaymentTextFieldType | PaymentTextFieldType.text | Keyboard, autofill and correction traits. |
size: | PaymentSize | PaymentSize.medium | Padding size; input text always remains 16 px. |
onChanged: | ValueChanged<String>? | — | Reports edits immediately; remote debounce belongs to the host. |
onSubmitted: | ValueChanged<String>? | — | Reports keyboard submission. |
textInputAction: | TextInputAction? | — | Keyboard action override. |
inputFormatters: | List<TextInputFormatter> | const [] | Host input constraints. |
textCapitalization: | TextCapitalization | TextCapitalization.none | Capitalization trait. |
keyboardType: | TextInputType? | — | Overrides the keyboard chosen by type. |
autofillHints: | Iterable<String>? | — | Overrides autofill traits. |
enabled: | bool | true | False disables editing and changes the edge and text. |
readOnly: | bool | false | Prevents edits while retaining the default appearance. |
reference: | bool | false | Uses reference typography and disables correction. |
prefixText: | String? | — | Text before the value. |
prefixIcon: | Widget? | — | Decorative leading content. |
suffix: | Widget? | — | Trailing content. |
PaymentTextField.search(…) — Controlled local list filter, with clear and refocus.
actions sit after the box on the same line, centred on it, such as a filter PaymentIconButton; a label above the box spans them. A hidden label (hiddenElements) shows as the placeholder instead and stays the field's spoken name.
| Parameter | Type | Default | Description |
|---|---|---|---|
key: | Key? | — | — |
query:required | String | — | — |
onChanged:required | ValueChanged<String> | — | — |
label: | String? | — | — |
actions: | List<Widget> | const [] | — |
hiddenElements: | Set<PaymentFieldPart> | const {} | — |
PaymentTextFieldType
enum PaymentTextFieldType · lib/src/controls/text_field.dart
Input traits; sensitive input belongs to the host.
| Value | Description |
|---|---|
text | Free text. |
number | Numeric quantity. |
tel | Telephone number. |
url | Web address. |
email | Email address. |
search | Local list filter. |
PaymentSize
enum PaymentSize · lib/src/foundation/payment_tokens.dart
Visual size only; layout box and hit area stay at least 48×48 dp. Components document their heights.
| Value | Description |
|---|---|
small | Module headers, table or chip rows; never the main action. |
medium | Default, today's visual size. |
large | One primary action on a full-screen wide view. |
PaymentFieldPart
enum PaymentFieldPart · lib/src/foundation/payment_tokens.dart
A hidden field part stays in semantics; consumers arrive in later phases.
| Value | Description |
|---|---|
label | Label field part. |
description | Description field part. |
error | Error field part. |
Field foundation
Section titled “Field foundation”Fields fill their parent. PaymentFormFieldGroup adds optional marks when required and optional fields are mixed. Use Text area for several lines.
Labels at large text: an outlined floating label keeps one line, so above 1.5× text every field (text, currency, date, select and search) shows its label above the box instead, where it wraps (#73). The box keeps its height, so fields of different types still line up, and the label stays the field’s spoken name. While the label is above, the hint shows only when the field has focus, as it does behind a floating label. Keep labels short anyway and put instructions in description.
Which variant when
Section titled “Which variant when”| Situation | Variant / composition | Payment example |
|---|---|---|
| History query | search | Use search for list filtering; labels persist after entry. |
Use Search field for selecting a known option.
Choose the type by what the value means:
| The value is… | Type |
|---|---|
| A filter for visible records | search |
| A number | number |
| A phone number, destination URL or email | tel, url or email |
| Any other non-secret single-line value | text |
Customization
Section titled “Customization”

PaymentFieldTheme is a Flutter theme extension for the field family: fill, resting outline color, corners and input typography. It applies to text, search, text-area, select, date, date-range field and currency fields, and to fields composed from them, such as the promo code input and identity form. Buttons, cards, sheets, chips, checkboxes, radios, switches and option lists keep their own styling. This page is the canonical guide for every field.
Fields have no per-instance style parameter. Adopt in this order:
- Product default: configure
PaymentThemeandPaymentFieldThemeonce in the app theme. Field call sites stay semantic. - Feature theme: a scoped
Themefor one subtree, such as a checkout form. - Host preset: a named host function that returns a
PaymentFieldThemefor a look repeated on several screens. Presets are host code, not kit API. - One-off: wrap the single field in a scoped
Theme. There is no inline field override.
Radius alone often needs no field theme: PaymentTheme.controlRadius changes inputs together with the other control-radius surfaces. Use PaymentFieldTheme.borderRadius when only fields should change.
Product default
Section titled “Product default”ThemeData paymentAppTheme(ColorScheme scheme) { final payment = PaymentTheme.fromColorScheme(scheme); return ThemeData( colorScheme: scheme, extensions: [ payment, PaymentFieldTheme( fillColor: payment.surfaceMuted, borderRadius: BorderRadius.circular(payment.space(PaymentSpace.group)), ), ], );}Feature theme and host preset
Section titled “Feature theme and host preset”Keep the parent’s other extensions when you scope a theme. A preset takes BuildContext and reads the current theme, so light, dark and brand changes follow; don’t freeze resolved colors in a top-level final.
// Host code: soft fields for the profile and payout forms.PaymentFieldTheme softFields(BuildContext context) { final payment = PaymentTheme.of(context); return PaymentFieldTheme( fillColor: payment.surfaceMuted, textStyle: const TextStyle(fontWeight: FontWeight.w500), );}
// Inside the feature's build method.final parent = Theme.of(context);return Theme( data: parent.copyWith(extensions: [ ...parent.extensions.values, softFields(context), ]), child: profileForm,);Nested themes replace the extension. To keep the parent’s field settings, start from parent.extension<PaymentFieldTheme>() and use copyWith; a null argument keeps the existing value.
Supported properties and states
Section titled “Supported properties and states”| Property | Effect |
|---|---|
fillColor |
Box fill while enabled or read-only. Unset, fields have no fill. A disabled field with a custom fill uses surfaceMuted. |
borderColor |
Resting outline while enabled. Unset, PaymentTheme.border. |
borderRadius |
Corners of every outline state and of the tap highlight on select and date triggers. Unset, controlBorderRadius. |
textStyle |
Typography merged over the input role for the entered value and placeholder. Color, paint, background, shadows, decoration and inherit are ignored. |
The kit keeps the 2 dp accent focus outline, the danger error outline, disabled colors and read-only behaviour, label, helper and error typography, content padding and sizes, prefix, suffix and clear controls, option lists and panels, motion and focus semantics. A custom font size or line height changes the text line, so the box follows the text like it does for system text size; it never drops below 48 dp. Keep both values positive. The currency field keeps the amount role for the entered amount and matches the themed input line height.
During theme transitions, concrete pairs interpolate. A property set at only one end switches at the midpoint, so null still means the kit default rather than a transparent fill or square corners. Ignored text fields are removed first.
The host checks contrast for a custom fill against the input text, placeholder and outline, in light and dark, and checks long values at 200% text.
States
Section titled “States”Default uses a border edge; focus uses a 2 px accent edge. Errors show an icon, message and danger edge, 2 px when focused. Disabled fields use disabled text and edge. Read-only retains default styling. Host errors hide after edits and return when the host passes a new error; pass null between identical attempts. Form validation timing belongs to the enclosing Form.
Layout. Small, medium and large fields are 48, 56 and 64 dp tall, and the text starts 16 dp in from the border at every size. Text, currency, date and select fields share these heights, so fields side by side line up.
Do and don’t
Section titled “Do and don’t”Do: Use search for list filtering; labels persist after entry.
Don’t: Collect PIN, OTP, password or card secrets.
Content guidelines
Section titled “Content guidelines”Keep the label visible after entry. Use the hint for an example and the error message for a specific correction.
Accessibility
Section titled “Accessibility”Keep labels, helper text and errors available to assistive technology. Focus uses an accent edge; an error includes an icon and message.
In the example app
Section titled “In the example app”

PaymentTextField
class PaymentTextField extends StatefulWidget · lib/src/controls/text_field.dart
Labeled single-line input integrated with Form validation.
| Parameter | Type | Default | Description |
|---|---|---|---|
label:required | String | — | Always visible; floats above the value, or sits above the box and wraps when text is scaled above 1.5×. |
controller: | TextEditingController? | — | Host-owned editing controller. |
initialValue: | String? | — | Starting value when no controller is supplied. |
focusNode: | FocusNode? | — | Host focus node; otherwise owned internally. |
hint: | String? | — | Supplemental hint; never the only instruction. |
description: | String? | — | Caption beneath the field. |
descriptionTone: | StatusTone | StatusTone.neutral | Optional semantic tone for the description. |
errorText: | String? | — | Host error; hides on edit. Pass null between identical attempts. |
validator: | FormFieldValidator<String>? | — | Form validation; errors include an icon. |
required: | bool | false | Spoken as required; enforced by the host validator. |
hiddenElements: | Set<PaymentFieldPart> | const {} | Hidden parts remain in semantics. |
type: | PaymentTextFieldType | PaymentTextFieldType.text | Keyboard, autofill and correction traits. |
size: | PaymentSize | PaymentSize.medium | Padding size; input text always remains 16 px. |
onChanged: | ValueChanged<String>? | — | Reports edits immediately; remote debounce belongs to the host. |
onSubmitted: | ValueChanged<String>? | — | Reports keyboard submission. |
textInputAction: | TextInputAction? | — | Keyboard action override. |
inputFormatters: | List<TextInputFormatter> | const [] | Host input constraints. |
textCapitalization: | TextCapitalization | TextCapitalization.none | Capitalization trait. |
keyboardType: | TextInputType? | — | Overrides the keyboard chosen by type. |
autofillHints: | Iterable<String>? | — | Overrides autofill traits. |
enabled: | bool | true | False disables editing and changes the edge and text. |
readOnly: | bool | false | Prevents edits while retaining the default appearance. |
reference: | bool | false | Uses reference typography and disables correction. |
prefixText: | String? | — | Text before the value. |
prefixIcon: | Widget? | — | Decorative leading content. |
suffix: | Widget? | — | Trailing content. |
PaymentTextField.search(…) — Controlled local list filter, with clear and refocus.
actions sit after the box on the same line, centred on it, such as a filter PaymentIconButton; a label above the box spans them. A hidden label (hiddenElements) shows as the placeholder instead and stays the field's spoken name.
| Parameter | Type | Default | Description |
|---|---|---|---|
key: | Key? | — | — |
query:required | String | — | — |
onChanged:required | ValueChanged<String> | — | — |
label: | String? | — | — |
actions: | List<Widget> | const [] | — |
hiddenElements: | Set<PaymentFieldPart> | const {} | — |
PaymentTextFieldType
enum PaymentTextFieldType · lib/src/controls/text_field.dart
Input traits; sensitive input belongs to the host.
| Value | Description |
|---|---|
text | Free text. |
number | Numeric quantity. |
tel | Telephone number. |
url | Web address. |
email | Email address. |
search | Local list filter. |
PaymentSize
enum PaymentSize · lib/src/foundation/payment_tokens.dart
Visual size only; layout box and hit area stay at least 48×48 dp. Components document their heights.
| Value | Description |
|---|---|
small | Module headers, table or chip rows; never the main action. |
medium | Default, today's visual size. |
large | One primary action on a full-screen wide view. |
PaymentFieldPart
enum PaymentFieldPart · lib/src/foundation/payment_tokens.dart
A hidden field part stays in semantics; consumers arrive in later phases.
| Value | Description |
|---|---|
label | Label field part. |
description | Description field part. |
error | Error field part. |
PaymentFieldTheme
class PaymentFieldTheme extends ThemeExtension<PaymentFieldTheme> · lib/src/foundation/field_style.dart
Field-family appearance registered in ThemeData.extensions (D102).
Applies to the input box of text, search, text-area, select, date, date-range-field and currency fields, and to fields composed from them (promo code, identity form). Buttons, cards, sheets, chips, selection controls and option lists or panels are unaffected.
Theme-only: there is no per-field style parameter. Scope a one-off with a nested Theme, keeping unrelated extensions:
``dart Theme( data: Theme.of(context).copyWith( extensions: [ ...Theme.of(context).extensions.values, PaymentFieldTheme(fillColor: PaymentTheme.of(context).surfaceMuted), ], ), child: form, ) ``
Every property is optional; null keeps the kit default, and an empty theme renders exactly like no theme. The kit keeps the 2 dp accent focus border, the danger error border, disabled and read-only behaviour, label, helper and error typography, content padding and sizes, the 48 dp minimum, prefix, suffix and clear controls, and focus semantics. Hosts verify contrast for a custom fill against the text and border colors in light and dark.
| Parameter | Type | Default | Description |
|---|---|---|---|
fillColor: | Color? | — | Box fill while enabled or read-only. Unset, fields have no fill. A disabled field with a custom fill shows |
borderColor: | Color? | — | Resting outline color while enabled; defaults to PaymentTheme.border. Focus, error and disabled outlines stay kit-owned. |
borderRadius: | BorderRadius? | — | Box corners for every outline state and the tap highlight; defaults to PaymentTheme.controlBorderRadius (D101). |
textStyle: | TextStyle? | — | Typography merged over the input role for the entered value and the placeholder, keeping unspecified fields. Color, paint, background, shadows, decorations and |