0

I want to make use of a TextFormField in my flutter app.

The text input field is show with the label. The hint text is not visible. When I select the widget, the hint text is shown and at the same time the label style changes. The text shrinks and become blue.

I tried this by just adding the code in the default flutter app, so it easy to reproduce

TextFormField( decoration: InputDecoration( labelText: "Demo Label", hintText: "Foo" )

Where can I change this behaviour? I would like to have a consistent label, no matter if the widget is selected or not.

user3412673
  • 77
  • 1
  • 3
  • 10
  • Similar question to https://stackoverflow.com/questions/56411599/flutter-textformfield-change-labelcolor-on-focus – Glen Aug 05 '19 at 21:17
  • 1
    The other question is to modify the label when it has focus. I want to have a label which is consistent no matter if the widget has focus or not. Also when text is entered or not, the label is the same. I woud be nice if I can control everything via the app theme. – user3412673 Aug 08 '19 at 19:26
  • Any solution found for this? – Tim Dirks Mar 02 '20 at 09:44

1 Answers1

0

Add your own Text widget for the label text, do not use "labelText" property in decoration property of TextFormField.

Text("Email", style: TextStyle()), <-- use custom Text widget
TextFormField(
  decoration: InputDecoration(
    //labelText: "Email",      <-- do not use this
    //labelStyle: TextStyle(), <-- do not use this
    hintText: "Please enter your email",
    hintStyle: TextStyle(),
  )
)