简体   繁体   中英

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) {
        ...

在此处输入图像描述

everybody somebody anybody help me body: TextFormField(),

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(),)

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)),
          ),
        ),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM