SILENMUS
SILENMUS

Reputation: 947

How to change TextFormField() widget color Flutter

I changed primary color black to white. my all TextFormField() focus color became white. how can I change this Color I tryed to change color properties but doens't work at all

 TextFormField(
     style: TextStyle(color: Colors.grey),
     focusNode: _confirmPasswordFocusNode,
     obscureText: true,
     decoration: InputDecoration(
     fillColor: Colors.black54,
     hoverColor: Colors.black54,
     focusColor: Colors.black54,
     labelText: '비밀번호 확인',
     icon: Icon(Icons.lock_outline)),
     onChanged: (value) {
        ...

enter image description here

everybody somebody anybody help me body : TextFormField(),

Upvotes: 0

Views: 1714

Answers (2)

Lapa Ny Aina Tanjona
Lapa Ny Aina Tanjona

Reputation: 1268

It doesn't change because of the default scheme set to the screen.

You just have to change the widgets that you are drawing by wrapping your TextFormField with new ThemeData()

      Theme(
          data: new ThemeData(
            primaryColor: Colors.black54,
            focusColor: Colors.black54,
            hintColor: Colors.black54,
          ),
          child: TextFormField(
            style: TextStyle(color: Colors.grey),
            obscureText: true,
            decoration: InputDecoration(
                labelText: '비밀번호 확인', icon: Icon(Icons.lock_outline)),
          ),
        ),

Upvotes: 0

CH Wing
CH Wing

Reputation: 1191

put cursorColor: Colors.white, inside TextFormField

TextField(
  cursorColor: Colors.red,
),

or

set the cursorColor for theme attribute when calling MaterialApp like

    MaterialApp(
        title: "Flutter App",
        theme: ThemeData(
        cursorColor: Colors.red,
        home: HomeScreen(),)

Upvotes: 1

Related Questions