decorator
A decorator used to create custom text fields based on Material Design outlined text field.
If your text field requires customising elements that aren't exposed by OutlinedTextField, such as the border thickness, consider using this decorator to achieve the desired design.
For example, if you wish to customize the thickness of the border, you can pass a custom Container to this decoration box's container.
This decorator is meant to be used in conjunction with the overload of BasicTextField that accepts a TextFieldDecorator parameter. For other overloads of BasicTextField that use a decorationBox, see DecorationBox.
An example of building a custom text field using decorator:
Parameters
TextFieldState object that holds the internal editing state of the text field.
the enabled state of the text field. When false, this decorator will appear visually disabled. This must be the same value that is passed to BasicTextField.
whether the text field is SingleLine or MultiLine. This must be the same value that is passed to BasicTextField.
OutputTransformation that transforms how the contents of the text field are presented. This must be the same value that is passed to BasicTextField.
the read-only InteractionSource representing the stream of Interactions for this text field. You must first create and pass in your own remembered MutableInteractionSource instance to the BasicTextField for it to dispatch events. And then pass the same instance to this decorator to observe Interactions and customize the appearance/behavior of the text field in different states.
the position of the label. See TextFieldLabelPosition.
the optional label to be displayed with this text field. The default text style uses Typography.bodySmall when minimized and Typography.bodyLarge when expanded.
the optional placeholder to be displayed when the input text is empty. The default text style uses Typography.bodyLarge.
the optional leading icon to be displayed at the beginning of the text field container.
the optional trailing icon to be displayed at the end of the text field container.
the optional prefix to be displayed before the input text in the text field.
the optional suffix to be displayed after the input text in the text field.
the optional supporting text to be displayed below the text field.
indicates if the text field's current value is in an error state. When true, this decorator will display its contents in an error color.
TextFieldColors that will be used to resolve the colors used for this text field decorator in different states. See OutlinedTextFieldDefaults.colors. Note: This parameter only affects the colors of elements in the decoration box. Elements of the BasicTextField (such as text color or cursor color) are unaffected and must be changed using the relevant parameters of BasicTextField.
the padding between the input field and the surrounding elements of the decorator. Note that the padding values may not be respected if they are incompatible with the text field's size constraints or layout. See OutlinedTextFieldDefaults.contentPadding.