Search code examples
fluttercolorsstylestextfield

How to change color style of TextField in flutter


I have a simple TextField widget like this

TextField(
      obscureText: widget.placeholder == "Password" ? _isHidePassword : false,
      decoration: InputDecoration(
        
        hintText: "${widget.placeholder}",
        hintStyle: TextStyle(
          color: Colors.grey,
        ),
        // labelText: "${widget.placeholder}",
        // labelStyle: TextStyle(color: greenMain),
      ),
    )

and it gives the result like this picture: enter image description here

is there a way to change the blue color into another? like red or green one ?


Solution

  • lets try

    Theme(
            data: new ThemeData(
              primaryColor: Colors.redAccent,
              primaryColorDark: Colors.red,
            ),
            child: TextField(
              keyboardType: TextInputType.text,
              decoration: InputDecoration(
                
                labelText: "Text field*",
              ),
            ),
          ),