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),
),
),
);
}
}Interactive preview
Resolving preview metadata...
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,
bool error = false,
TextInputType? keyboardType,
TextInputAction? textInputAction,
TextCapitalization textCapitalization = TextCapitalization.none,
TextDirection? textDirection,
bool obscureText = false,
bool enabled = true,
bool readOnly = false,
bool autofocus = false,
int? maxLines = 1,
int? minLines,
bool expands = false,
int? maxLength,
MaxLengthEnforcement? maxLengthEnforcement,
ValueChanged<String>? onChanged,
VoidCallback? onEditingComplete,
ValueChanged<String>? onSubmitted,
AppPrivateCommandCallback? onAppPrivateCommand,
List<TextInputFormatter>? inputFormatters,
bool? showCursor,
String obscuringCharacter = '•',
bool autocorrect = true,
bool enableSuggestions = true,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
bool enableInteractiveSelection = true,
TextSelectionControls? selectionControls,
TapRegionCallback? onTapOutside,
TapRegionUpCallback? onPressUpOutside,
bool onTapAlwaysCalled = false,
ScrollController? scrollController,
ScrollPhysics? scrollPhysics,
Iterable<String>? autofillHints,
ContentInsertionConfiguration? contentInsertionConfiguration,
Clip clipBehavior = Clip.hardEdge,
String? restorationId,
bool stylusHandwritingEnabled = true,
bool enableIMEPersonalizedLearning = true,
EditableTextContextMenuBuilder? contextMenuBuilder,
SpellCheckConfiguration? spellCheckConfiguration,
TextMagnifierConfiguration? magnifierConfiguration,
bool canRequestFocus = true,
bool? ignorePointers,
UndoHistoryController? undoController,
Object groupId = EditableText,
Widget? leading,
Widget? trailing,
String? semanticLabel,
String? semanticHint,
bool excludeSemantics = false,
RemixTextFieldStyle style = const RemixTextFieldStyle.create(),
RemixTextFieldSpec? styleSpec,
})Properties
Widget Properties
| Prop | Type | Required / Default Value |
|---|---|---|
key | Key? | Optional. Controls how one widget replaces another widget in the tree. |
controller | TextEditingController? | Optional. Controls the text being edited. |
focusNode | FocusNode? | Optional. Defines the keyboard focus for this widget. |
keyboardType | TextInputType? | Optional. The type of keyboard to use for editing the text. |
textInputAction | TextInputAction? | Optional. The type of action button to use for the keyboard. |
textCapitalization | TextCapitalization | Optional. Configures how the platform keyboard will select an uppercase or lowercase keyboard. |
textDirection | TextDirection? | Optional. The directionality of the text. |
readOnly | bool | Optional. Whether the text can be changed. |
showCursor | bool? | Optional. Whether to show cursor. |
autofocus | bool | Optional. Whether this text field should focus itself if nothing else is already focused. |
obscuringCharacter | String | Optional. Character used for obscuring text if obscureText is true. |
obscureText | bool | Optional. Whether to hide the text being edited. |
autocorrect | bool | Optional. Whether to enable autocorrect. |
enableSuggestions | bool | Optional. Whether to show input suggestions as the user types. |
smartDashesType | SmartDashesType? | Optional. Configuration for smart dashes. |
smartQuotesType | SmartQuotesType? | Optional. Configuration for smart quotes. |
maxLines | int? | Optional. The maximum number of lines for the text to span. |
minLines | int? | Optional. The minimum number of lines to occupy when the content spans fewer lines. |
expands | bool | Optional. Whether this widget’s height will be sized to fill its parent. |
maxLength | int? | Optional. The maximum number of characters to allow in the text field. |
maxLengthEnforcement | MaxLengthEnforcement? | Optional. How the maxLength limit should be enforced. |
onChanged | ValueChanged<String>? | Optional. Called when the user initiates a change to the TextField’s value. |
onEditingComplete | VoidCallback? | Optional. Called when the user submits editable content. |
onSubmitted | ValueChanged<String>? | Optional. Called when the user indicates that they are done editing the text in the field. |
onAppPrivateCommand | AppPrivateCommandCallback? | Optional. This is used to receive a private command from the input method. |
inputFormatters | List<TextInputFormatter>? | Optional. Optional input formatters. |
enabled | bool | Optional. Whether the text field is enabled. |
dragStartBehavior | DragStartBehavior | Optional. Defines how to handle drag start behavior. |
enableInteractiveSelection | bool | Optional. Whether to enable user interface affordances for changing the text selection. |
selectionControls | TextSelectionControls? | Optional. Optional delegate for building the text selection handles and toolbar. |
onTapOutside | TapRegionCallback? | Optional. Called when the user taps outside of this text field. |
onPressUpOutside | TapRegionUpCallback? | Optional. Called when tap up is detected outside of this text field. |
onTapAlwaysCalled | bool | Optional. Whether onTap should be called for every tap. |
scrollController | ScrollController? | Optional. The ScrollController to use when vertically scrolling the input. |
scrollPhysics | ScrollPhysics? | Optional. The ScrollPhysics to use when vertically scrolling the input. |
autofillHints | Iterable<String>? | Optional. A list of strings that helps the autofill service identify the type of this text input. |
contentInsertionConfiguration | ContentInsertionConfiguration? | Optional. Configuration for content insertion. |
clipBehavior | Clip | Optional. The content will be clipped (or not) according to this option. |
restorationId | String? | Optional. Restoration ID to save and restore the state of the text field. |
stylusHandwritingEnabled | bool | Optional. Whether stylus handwriting is enabled. |
enableIMEPersonalizedLearning | bool | Optional. Whether to enable that the IME update personalized data. |
contextMenuBuilder | EditableTextContextMenuBuilder? | Optional. A context menu builder for the text field. |
spellCheckConfiguration | SpellCheckConfiguration? | Optional. Configuration for spell checking. |
magnifierConfiguration | TextMagnifierConfiguration? | Optional. Configuration for text magnification. |
canRequestFocus | bool | Optional. Whether this text field can request focus. |
ignorePointers | bool? | Optional. Whether to ignore pointer events. |
undoController | UndoHistoryController? | Optional. Undo controller for managing undo/redo operations. |
groupId | Object | Optional. The group ID for the text field. |
hintText | String? | Optional. Hint text to display when the text field is empty. |
helperText | String? | Optional. Helper text to display below the text field. |
label | String? | Optional. Label text to display above the text field. |
error | bool | Optional. Whether the text field is in error state. |
styleSpec | RemixTextFieldSpec? | Optional. The style spec for the text field. |
leading | Widget? | Optional. A widget to display at the leading edge of the text field. |
trailing | Widget? | Optional. A widget to display at the trailing edge of the text field. |
semanticLabel | String? | Optional. The semantic label for the text field. |
semanticHint | String? | Optional. The semantic hint for the text field. |
excludeSemantics | bool | Optional. Whether to exclude child semantics. |
style | RemixTextFieldStyle | Optional. The style configuration for the text field. |
Style Methods
| Method | Description |
|---|---|
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 style using a TextStyler. |
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) | Applies widget modifiers such as clipping, opacity, or scaling. |
foregroundDecoration(DecorationMix value) | Sets a foreground decoration painted on top of the component. |
transform(Matrix4 value, AlignmentGeometry alignment = Alignment.center) | Applies a matrix transformation to the component. |
flex(FlexStyler value) | Configures the flex layout properties. |
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 |
Last updated on