Skip to content
Get started
Menu
Get started

Text field

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

Name fields in three sizes and receipt, phone, promo, order and company fields with validation and disabled states.Name fields in three sizes and receipt, phone, promo, order and company fields with validation and disabled states.
Text field
Name fields in three sizes, receipt email, an invalid phone number, promo code, order ID, a disabled company field and search at 200 percent text. Part 1 of 2.Continued: Name fields in three sizes, receipt email, an invalid phone number, promo code, order ID, a disabled company field and search at 200 percent text. Part 2 of 2.
200% text Shown in 2 images, top to bottom; each repeats the last few lines of the one before.
Name, receipt email, phone, promo, order, disabled company and search fields at 200 percent text in Indonesian. Part 1 of 2.Continued: Name, receipt email, phone, promo, order, disabled company and search fields at 200 percent text in Indonesian. Part 2 of 2.
200% text, Indonesian Shown in 2 images, top to bottom; each repeats the last few lines of the one before.
Transaction history search
Gallery: transaction history, Indonesian

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'),
],
),
);
}

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: text, number, tel, url, email, search; small, medium, large.

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.

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.

ParameterTypeDefaultDescription
label:requiredString—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:StatusToneStatusTone.neutralOptional 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:boolfalseSpoken as required; enforced by the host validator.
hiddenElements:Set<PaymentFieldPart>const {}Hidden parts remain in semantics.
type:PaymentTextFieldTypePaymentTextFieldType.textKeyboard, autofill and correction traits.
size:PaymentSizePaymentSize.mediumPadding 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:TextCapitalizationTextCapitalization.noneCapitalization trait.
keyboardType:TextInputType?—Overrides the keyboard chosen by type.
autofillHints:Iterable<String>?—Overrides autofill traits.
enabled:booltrueFalse disables editing and changes the edge and text.
readOnly:boolfalsePrevents edits while retaining the default appearance.
reference:boolfalseUses 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.

ParameterTypeDefaultDescription
key:Key?——
query:requiredString——
onChanged:requiredValueChanged<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.

ValueDescription
textFree text.
numberNumeric quantity.
telTelephone number.
urlWeb address.
emailEmail address.
searchLocal 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.

ValueDescription
smallModule headers, table or chip rows; never the main action.
mediumDefault, today's visual size.
largeOne 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.

ValueDescription
labelLabel field part.
descriptionDescription field part.
errorError field part.

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.

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
Rounded filled fields share input typography while error and disabled states retain their meaning; the button keeps its own theme.Rounded filled fields share input typography while error and disabled states retain their meaning; the button keeps its own theme.
Field theme

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:

  1. Product default: configure PaymentTheme and PaymentFieldTheme once in the app theme. Field call sites stay semantic.
  2. Feature theme: a scoped Theme for one subtree, such as a checkout form.
  3. Host preset: a named host function that returns a PaymentFieldTheme for a look repeated on several screens. Presets are host code, not kit API.
  4. 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.

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)),
),
],
);
}

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.

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.

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: Use search for list filtering; labels persist after entry.

Don’t: Collect PIN, OTP, password or card secrets.

Keep the label visible after entry. Use the hint for an example and the error message for a specific correction.

Keep labels, helper text and errors available to assistive technology. Focus uses an accent edge; an error includes an icon and message.

Example kyc onboarding screen with synthetic dataExample kyc onboarding screen with synthetic data
Example: kyc onboarding

PaymentTextField

class PaymentTextField extends StatefulWidget · lib/src/controls/text_field.dart

Labeled single-line input integrated with Form validation.

ParameterTypeDefaultDescription
label:requiredString—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:StatusToneStatusTone.neutralOptional 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:boolfalseSpoken as required; enforced by the host validator.
hiddenElements:Set<PaymentFieldPart>const {}Hidden parts remain in semantics.
type:PaymentTextFieldTypePaymentTextFieldType.textKeyboard, autofill and correction traits.
size:PaymentSizePaymentSize.mediumPadding 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:TextCapitalizationTextCapitalization.noneCapitalization trait.
keyboardType:TextInputType?—Overrides the keyboard chosen by type.
autofillHints:Iterable<String>?—Overrides autofill traits.
enabled:booltrueFalse disables editing and changes the edge and text.
readOnly:boolfalsePrevents edits while retaining the default appearance.
reference:boolfalseUses 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.

ParameterTypeDefaultDescription
key:Key?——
query:requiredString——
onChanged:requiredValueChanged<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.

ValueDescription
textFree text.
numberNumeric quantity.
telTelephone number.
urlWeb address.
emailEmail address.
searchLocal 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.

ValueDescription
smallModule headers, table or chip rows; never the main action.
mediumDefault, today's visual size.
largeOne 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.

ValueDescription
labelLabel field part.
descriptionDescription field part.
errorError 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.

ParameterTypeDefaultDescription
fillColor:Color?—Box fill while enabled or read-only. Unset, fields have no fill.

A disabled field with a custom fill shows PaymentTheme.surfaceMuted.

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 inherit are ignored; the kit owns text colors per state. Font size and height must be positive when supplied. The box grows or shrinks with the text line, never below 48 dp. Currency fields keep the amount role for the entered amount and match the themed input line height. Labels, helper and error text keep their roles.