Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change TextField cursor color in flutter

I'm using TextField widget in AppBar()

there is one problem , as you can see I cannot set cursor color when textfield focused

usually, textfield cursor blinks when it focused.

enter image description here

I set cursor color property , every color property in appbar, textfield but it doesn't work even textfield hint text doens't work too.

            appBar: AppBar(
              title: Card(
                margin: EdgeInsets.only(
                    top: common_gap * 1.5, bottom: common_gap * 1.5),
                child: TextField(
                  cursorColor: Constants.kPrimaryOrange,
                  controller: _controller,
                  focusNode: _focusNode,
                  onChanged: (value) {
                    setState(() {
                      _searchText = value;
                    });
                  },
                  decoration: InputDecoration(
                    prefixIcon: Icon(
                      Icons.search,
                      size: 20,
                    ),
                    suffixIcon: _controller.text.length != 0
                        ? IconButton(
                            icon: Icon(
                              Icons.cancel,
                              size: 20,
                              color: _searchText == ''
                                  ? Colors.transparent
                                  : Colors.black87,
                            ),
                            onPressed: () {
                              setState(() {
                                _controller.clear();
                                _searchText = '';
                                _focusNode.unfocus();
                              });
                            },
                          )
                        : Container(),
                  ),

                ),

can you tell me how to fix this ??

like image 391
SILENMUS Avatar asked Sep 02 '25 15:09

SILENMUS


1 Answers

You can change specific textfield cursor color for your solution:

TextField(cursorColor: Colors.white)

but if you want to change it for all out you project then you can check this here

like image 108
shorol Avatar answered Sep 05 '25 14:09

shorol