TextField

A text input component for collecting user text input with labels, hints, and validation support

A text input component for collecting user text input with labels, hints, and helper text.

When to use this

  • Form inputs: Collect text data in forms (names, emails, addresses)
  • Search fields: Enable users to enter search queries
  • Comments: Allow users to enter text comments or feedback
  • Data entry: Capture any text-based user input

Basic implementation

Basic implementation
import 'package:flutter/material.dart';
import 'package:remix/remix.dart';

class TextfieldExample extends StatefulWidget {
  const TextfieldExample({super.key});

  @override
  State<TextfieldExample> createState() => _TextfieldExampleState();
}

class _TextfieldExampleState extends State<TextfieldExample> {
  final controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: 300,
      child: RemixTextField(
        controller: controller,
        hintText: 'Placeholder',
        label: 'Label',
        helperText: 'Required field',
        style: style,
      ),
    );
  }

  RemixTextFieldStyle get style {
    return RemixTextFieldStyle()
        .color(Colors.grey.shade800)
        .backgroundColor(Colors.white)
        .borderRadiusAll(const Radius.circular(8.0))
        .height(44)
        .paddingX(12)
        .spacing(8)
        .label(
          TextStyler()
              .color(Colors.blueGrey.shade900)
              .fontWeight(FontWeight.w500),
        )
        .helperText(
          TextStyler()
              .fontWeight(FontWeight.w300)
              .color(Colors.blueGrey.shade600),
        )
        .hintColor(Colors.blueGrey.shade500)
        .shadow(
          BoxShadowMix()
              .blurRadius(1)
              .color(Colors.black12)
              .offset(const Offset(0, 1)),
        )
        .border(
          BoxBorderMix.all(BorderSideMix(color: Colors.grey.shade300)),
        )
        .onFocused(
          RemixTextFieldStyle().border(
            BoxBorderMix.all(
              BorderSideMix()
                  .color(Colors.deepPurpleAccent)
                  .width(3)
                  .strokeAlign(BorderSide.strokeAlignCenter),
            ),
          ),
        );
  }
}

Fortal styles

Remix includes Fortal-themed style helpers for this component:

Fortal base style
import 'package:flutter/material.dart';
import 'package:remix/remix.dart';

class FortalTextFieldExample extends StatefulWidget {
  const FortalTextFieldExample({super.key});

  @override
  State<FortalTextFieldExample> createState() => _FortalTextFieldExampleState();
}

class _FortalTextFieldExampleState extends State<FortalTextFieldExample> {
  final controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Column(
      spacing: 16,
      children: [
        RemixTextField(
          controller: controller,
          label: 'Email',
          hintText: 'Enter your email',
          style: FortalTextFieldStyle.base(),
        ),
        RemixTextField(
          controller: controller,
          label: 'Password',
          hintText: 'Enter password',
          obscureText: true,
          style: FortalTextFieldStyle.base(),
        ),
      ],
    );
  }
}

See the FortalTextFieldStyle source code for all available options.

Constructor

Constructor
const RemixTextField({
  Key? key,
  TextEditingController? controller,
  FocusNode? focusNode,
  String? label,
  String? hintText,
  String? helperText,
  String? errorText,
  TextInputType? keyboardType,
  TextInputAction? textInputAction,
  bool obscureText = false,
  bool enabled = true,
  bool readOnly = false,
  bool autofocus = false,
  int? maxLines = 1,
  int? maxLength,
  ValueChanged<String>? onChanged,
  VoidCallback? onEditingComplete,
  ValueChanged<String>? onSubmitted,
  RemixTextFieldStyle style = const RemixTextFieldStyle.create(),
  RemixTextFieldSpec? styleSpec,
})

Properties

Widget Properties

keyKey?

Optional. Controls how one widget replaces another widget in the tree.

controllerTextEditingController?

Optional. Controls the text being edited.

focusNodeFocusNode?

Optional. Defines the keyboard focus for this widget.

keyboardTypeTextInputType?

Optional. The type of keyboard to use for editing the text.

textInputActionTextInputAction?

Optional. The type of action button to use for the keyboard.

textCapitalizationTextCapitalization

Optional. Configures how the platform keyboard will select an uppercase or lowercase keyboard.

textDirectionTextDirection?

Optional. The directionality of the text.

readOnlybool

Optional. Whether the text can be changed.

showCursorbool?

Optional. Whether to show cursor.

autofocusbool

Optional. Whether this text field should focus itself if nothing else is already focused.

obscuringCharacterString

Optional. Character used for obscuring text if obscureText is true.

obscureTextbool

Optional. Whether to hide the text being edited.

autocorrectbool

Optional. Whether to enable autocorrect.

enableSuggestionsbool

Optional. Whether to show input suggestions as the user types.

smartDashesTypeSmartDashesType?

Optional. Configuration for smart dashes.

smartQuotesTypeSmartQuotesType?

Optional. Configuration for smart quotes.

maxLinesint?

Optional. The maximum number of lines for the text to span.

minLinesint?

Optional. The minimum number of lines to occupy when the content spans fewer lines.

expandsbool

Optional. Whether this widget's height will be sized to fill its parent.

maxLengthint?

Optional. The maximum number of characters to allow in the text field.

maxLengthEnforcementMaxLengthEnforcement?

Optional. How the maxLength limit should be enforced.

onChangedValueChanged<String>?

Optional. Called when the user initiates a change to the TextField's value.

onEditingCompleteVoidCallback?

Optional. Called when the user submits editable content.

onSubmittedValueChanged<String>?

Optional. Called when the user indicates that they are done editing the text in the field.

onAppPrivateCommandAppPrivateCommandCallback?

Optional. This is used to receive a private command from the input method.

inputFormattersList<TextInputFormatter>?

Optional. Optional input formatters.

enabledbool

Optional. Whether the text field is enabled.

dragStartBehaviorDragStartBehavior

Optional. Defines how to handle drag start behavior.

enableInteractiveSelectionbool

Optional. Whether to enable user interface affordances for changing the text selection.

selectionControlsTextSelectionControls?

Optional. Optional delegate for building the text selection handles and toolbar.

onTapOutsideTapRegionCallback?

Optional. Called when the user taps outside of this text field.

onPressUpOutsideTapRegionUpCallback?

Optional. Called when tap up is detected outside of this text field.

onTapAlwaysCalledbool

Optional. Whether onTap should be called for every tap.

scrollControllerScrollController?

Optional. The ScrollController to use when vertically scrolling the input.

scrollPhysicsScrollPhysics?

Optional. The ScrollPhysics to use when vertically scrolling the input.

autofillHintsIterable<String>?

Optional. A list of strings that helps the autofill service identify the type of this text input.

contentInsertionConfigurationContentInsertionConfiguration?

Optional. Configuration for content insertion.

clipBehaviorClip

Optional. The content will be clipped (or not) according to this option.

restorationIdString?

Optional. Restoration ID to save and restore the state of the text field.

stylusHandwritingEnabledbool

Optional. Whether stylus handwriting is enabled.

enableIMEPersonalizedLearningbool

Optional. Whether to enable that the IME update personalized data.

contextMenuBuilderEditableTextContextMenuBuilder?

Optional. A context menu builder for the text field.

spellCheckConfigurationSpellCheckConfiguration?

Optional. Configuration for spell checking.

magnifierConfigurationTextMagnifierConfiguration?

Optional. Configuration for text magnification.

canRequestFocusbool

Optional. Whether this text field can request focus.

ignorePointersbool?

Optional. Whether to ignore pointer events.

undoControllerUndoHistoryController?

Optional. Undo controller for managing undo/redo operations.

groupIdObject

Optional. The group ID for the text field.

hintTextString?

Optional. Hint text to display when the text field is empty.

helperTextString?

Optional. Helper text to display below the text field.

labelString?

Optional. Label text to display above the text field.

errorbool

Optional. Whether the text field is in error state.

styleSpecRemixTextFieldSpec?

Optional. The style spec for the text field.

leadingWidget?

Optional. A widget to display at the leading edge of the text field.

trailingWidget?

Optional. A widget to display at the trailing edge of the text field.

onPressedVoidCallback?

Optional. Called when the text field is pressed (for tap interactions).

semanticLabelString?

Optional. The semantic label for the text field.

semanticHintString?

Optional. The semantic hint for the text field.

excludeSemanticsbool

Optional. Whether to exclude child semantics.

styleRemixTextFieldStyle

Optional. The style configuration for the text field.

Style Methods

color(Color value)

Sets text color

backgroundColor(Color value)

Sets background color

container(FlexBoxStyler value)

Sets container that wraps editable text area

borderRadius(BorderRadiusGeometryMix radius)

Sets border radius

padding(EdgeInsetsGeometryMix value)

Sets padding

border(BoxBorderMix value)

Sets border

width(double value)

Sets width

height(double value)

Sets height

cursorColor(Color value)

Sets cursor color

hintColor(Color value)

Sets hint text color

hintText(TextStyler value)

Sets hint text color

margin(EdgeInsetsGeometryMix value)

Sets margin

spacing(double value)

Sets flex spacing

decoration(DecorationMix value)

Sets decoration

alignment(Alignment value)

Sets container alignment

constraints(BoxConstraintsMix value)

Sets constraints

textAlign(TextAlign value)

Sets text alignment

helperText(TextStyler value)

Sets helper text

label(TextStyler value)

Sets label text

animate(AnimationConfig animation)

Sets animation

wrap(WidgetModifierConfig value)

foregroundDecoration(DecorationMix value)

transform(Matrix4 value, AlignmentGeometry alignment = Alignment.center)

flex(FlexStyler value)

labelTextStyle(TextStyleMix value)

Sets label/text style using TextStyleMix directly

labelColor(Color value)

Sets label/text color

labelFontSize(double value)

Sets label/text font size

labelFontWeight(FontWeight value)

Sets label/text font weight

labelFontStyle(FontStyle value)

Sets label/text font style (italic/normal)

labelLetterSpacing(double value)

Sets label/text letter spacing

labelDecoration(TextDecoration value)

Sets label/text decoration (underline, strikethrough, etc.)

labelFontFamily(String value)

Sets label/text font family

labelHeight(double value)

Sets label/text line height

labelWordSpacing(double value)

Sets label/text word spacing

labelDecorationColor(Color value)

Sets label/text decoration color