FluentInput class
A Fluent 2 single-line text field.
FluentInput(
controller: controller,
placeholder: const Text('Search'),
contentBefore: const Icon(FluentIcons.search_20_regular),
onSubmitted: search,
)
Built directly on EditableText — package:flutter/material.dart is not a
dependency of this package, so TextField does not exist here. Caret
placement, drag selection, double-tap word selection and long-press come
from TextSelectionGestureDetectorBuilder, the widgets-layer machinery
TextField itself uses; the handles come from
FluentTextSelectionControls.
Pass enabled: false to disable it — disabled is a real state here, not a
visual treatment: the field stops reporting hover and press, refuses edits,
swaps to the disabled token ramp wholesale, and loses its focus bar
entirely, matching upstream's ::after { content: unset }.
There is no focus ring. Upstream writes
:focus-within { outline: 2px solid transparent } — deliberately
suppressing the shared ring — and Figma's twelve State=Focus variants draw
only the brand bar. The growing underline is the focus indicator.
Customisation follows the usual three rungs. style is merged last and wins; FluentInputTheme restyles a subtree; and for anything further, resolveFluentInputState, resolveFluentInputStyle and buildFluentInput are public so any one of them can be replaced without forking this widget.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FluentInput
Constructors
-
FluentInput({Key? key, TextEditingController? controller, FocusNode? focusNode, FluentInputAppearance appearance = FluentInputAppearance.outline, FluentInputSize size = FluentInputSize.medium, Widget? placeholder, Widget? contentBefore, Widget? contentAfter, bool enabled = true, bool readOnly = false, bool error = false, bool obscureText = false, int? maxLines = 1, int? minLines, TextInputType? keyboardType, TextInputAction? textInputAction, ValueChanged<
String> ? onChanged, ValueChanged<String> ? onSubmitted, bool autofocus = false, Iterable<String> ? autofillHints, FluentInputStyle? style, String? semanticLabel}) -
Creates a text field.
const
Properties
- appearance → FluentInputAppearance
-
Fill and outline treatment.
final
-
autofillHints
→ Iterable<
String> ? -
Autofill categories for this field, e.g.
[AutofillHints.username].final - autofocus → bool
-
Whether to take focus on mount.
final
- contentAfter → Widget?
-
Slot after the field in reading order.
final
- contentBefore → Widget?
-
Slot before the field in reading order — an icon, a prefix, a button.
final
- controller → TextEditingController?
-
The value being edited. One is created internally when omitted.
final
- enabled → bool
-
Whether the field accepts input. False is a real disabled state.
final
- error → bool
-
Whether to paint the validation-error treatment.
final
- focusNode → FocusNode?
-
Focus node to use. One is created internally when omitted.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardType → TextInputType?
-
Which soft keyboard to request.
final
- maxLines → int?
-
Maximum rendered lines, or null to grow without bound.
final
- minLines → int?
-
Minimum rendered lines.
final
- obscureText → bool
-
Whether characters are replaced by the obscuring character.
final
-
onChanged
→ ValueChanged<
String> ? -
Invoked on every edit.
final
-
onSubmitted
→ ValueChanged<
String> ? -
Invoked when the action key is pressed.
final
- placeholder → Widget?
-
Shown while the value is empty.
final
- readOnly → bool
-
Whether the value can be selected and copied but not edited.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
Announced by assistive technology. Use it when no visible label names the
field — a placeholder is not a label.
final
- size → FluentInputSize
-
Height and type ramp.
final
- style → FluentInputStyle?
-
Overrides layered over the theme defaults. Merged last, so it wins.
final
- textInputAction → TextInputAction?
-
The soft keyboard's action key.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< FluentInput> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited