How to change TextFormField input text color in Flutter

DartFlutter

Dart Problem Overview


Doing UI for a flutter app at uni, I just want the text typed into the TextFormField to be white. It seems unnecessarily difficult. I've tried googling etc but can't see an obvious answer.

  new Theme(
    // this colors the underline
    data: theme.copyWith(
      primaryColor: Colors.white,
      hintColor: Colors.transparent,
     
    ),
    child: new Padding(
      padding: const EdgeInsets.fromLTRB(32.0, 40.0, 32.0, 4.0),
      child: TextFormField(

          key: Key('username'),
          keyboardType: TextInputType.text,
          controller: usernameController,
          decoration: InputDecoration(

              fillColor: Colors.black.withOpacity(0.6),
              filled: true,
              border: new OutlineInputBorder(

                borderRadius: const BorderRadius.all(

                  const Radius.circular(8.0),
                ),
                borderSide: new BorderSide(
                  color: Colors.transparent,
                  width: 1.0,
                ),
              ),
              labelText: 'Username',
              labelStyle:
                  new TextStyle(color: Colors.white, fontSize: 16.0)),
          style:
              TextStyle(fontSize: 20.0, color: textTheme.button.color),
          validator: validateUserName,
          onSaved: (val) => this.loginFields._username = val),
    ),
  ),

Dart Solutions


Solution 1 - Dart

This will do:

TextFormField(
  style: TextStyle(color: Colors.white),
)

Solution 2 - Dart

Puedes usar style: TextStyle

body: Center(
    child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
            Form(
                key: _formKey,
                child: Column(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                        TextFormField(
                            TextFormField(
                                controller: field,
                                style: TextStyle(fontSize: 18, color: Colors.red),
                                decoration: const InputDecoration(
                                    contentPadding: const EdgeInsets.only(
                                        left: 15,
                                        top: 8,
                                        right: 15,
                                        bottom: 0
                                    ),
                                    hintText: 'name',
                                ),
                                validator: (value) {
                                    if (value.isEmpty) {
                                        return 'Please enter some text';
                                    }
                                    return null;
                                },
                            ),
                        )
                    ]
                )
            )
        ]
    )
)

Solution 3 - Dart

You can use this to change everything

TextFormField(
                //controller: _phoneController,
                cursorColor: Colors.black,
                keyboardType: TextInputType.text,
                style: TextStyle(
                  color: Colors.black
                ),
                decoration: new InputDecoration(
                  hintStyle: TextStyle(
                    color: Colors.white
                  ),
                    border: InputBorder.none,
                    //contentPadding:
                    //EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
                    hintText: "New Playlist"),
              ),

Solution 4 - Dart

Padding(
  padding: EdgeInsets.all(10),
  child: TextFormField(
  cursorColor: Color(0XFFFFCC00)//Cursor color change
  style: TextStyle(
    color: Color(0XFFFFCC00),
    decorationColor: Color(0XFFFFCC00),//Font color change
    backgroundColor: Color(0XFFFFCC00),//TextFormField title background color change
   ),
),

Solution 5 - Dart

You can use style inside TextFormField.

Example :
          TextFormField(
            style: const TextStyle(color: Colors.white),
          ),

Solution 6 - Dart

You are changing input text color in this line TextStyle(fontSize: 20.0, color: textTheme.button.color), so in order to set in to white just use Colors.white constant instead of textTheme.button.color.

More about text style here.

Solution 7 - Dart

Overview: The textFormField style is set to a TextStyle defined as MediumStyle. The style affects the characters being displayed in the textbox. Whereas, the labelStyle affect the font displays of the inputdecoration.

TextFormField(
            style: MediumStyle,
            keyboardType: TextInputType.emailAddress,
            focusNode: _employeeEmailFocus,
            decoration: InputDecoration(labelText: "Employee Email", labelStyle:MediumBoldStyle),
            validator: (val)=> null,
            onSaved:(value)=> this._employeeEmail=value,
            onFieldSubmitted: (term){
                _fieldFocusChange(context,_employeeEmailFocus,_passwordFocus);
            },

            ),

Solution 8 - Dart

For anyone trying to do this from a material app's theme: ThemeData property, the color can be changed using the subtitle1 text theme style.

MaterialApp(
  ...
  theme: ThemeData(
    ...
    textTheme: const TextTheme(
      ...
      subtitle1: const TextStyle(
        color: Colors.red, // <-- TextFormField input color
      ),
    ),
  ),
)

Solution 9 - Dart

Add a inputdecoration class for textformfield this is i think so

    decoration: InputDecoration(
              prefixStyle: new TextStyle(

              ),

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpoujoView Question on Stackoverflow
Solution 1 - DartdshukertjrView Answer on Stackoverflow
Solution 2 - DartJairo RodriguezView Answer on Stackoverflow
Solution 3 - DartpavelView Answer on Stackoverflow
Solution 4 - DartfucukurView Answer on Stackoverflow
Solution 5 - Dartdhaval_nakumView Answer on Stackoverflow
Solution 6 - Dartolexa.leView Answer on Stackoverflow
Solution 7 - DartGolden LionView Answer on Stackoverflow
Solution 8 - DartKwame Opare AsieduView Answer on Stackoverflow
Solution 9 - DartArchu MohanView Answer on Stackoverflow