floatingLabelStyle property

TextStyle? floatingLabelStyle
final

The style to use for InputDecoration.labelText when the label is above (i.e., vertically adjacent to) the input field.

When the InputDecoration.labelText is on top of the input field, the text uses the labelStyle instead.

If floatingLabelStyle is a MaterialStateTextStyle, then the effective text style can depend on the MaterialState.focused state, i.e. if the TextField is focused or not.

If null, defaults to labelStyle.

Specifying this style will override the default behavior of InputDecoration that changes the color of the label to the InputDecoration.errorStyle color or ColorScheme.error.

It's possible to override the label style for just the error state, or just the default state, or both.

In this example the floatingLabelStyle is specified with a MaterialStateProperty which resolves to a text style whose color depends on the decorator's error state.

link

To create a local project with this code sample, run:
flutter create --sample=material.InputDecoration.floatingLabelStyle.1 mysample

Implementation

final TextStyle? floatingLabelStyle;