简体   繁体   中英

How to change color of border line in TextFormField with Flutter

I would like to change the color of the border line in TextFormField. I would like to change the color blue to white.

在此处输入图像描述

I can not guess any of their properties.

              child: TextFormField(
                onChanged: (value) {
                  email = value;
                },
                style: TextStyle(color: Colors.white),
                keyboardType: TextInputType.emailAddress,
                autofocus: true,
                textAlign: TextAlign.center,
                cursorColor: Colors.white,
                decoration: InputDecoration(
                  filled: true,
                  fillColor: kTileColor,
                  enabledBorder: UnderlineInputBorder(
                    borderSide: BorderSide(
                        style: BorderStyle.none, color: Colors.white),
                  ),
                ),
              ),

How can I do it?

You only set the enabledBorder property to white . Set the focusedBorder property to white and it will give you your desired result.

You can achieve this by setting the focusedBorder property to your desired color.

Check the code below, it works fine:

            child: TextFormField(
                onChanged: (value) {
                  email = value;
                },
                style: TextStyle(color: Colors.white),
                keyboardType: TextInputType.emailAddress,
                autofocus: true,
                textAlign: TextAlign.center,
                cursorColor: Colors.white,
                decoration: InputDecoration(
                  filled: true,
                  fillColor: kTileColor,
                  enabledBorder: UnderlineInputBorder(
                    borderSide: BorderSide(
                        style: BorderStyle.none, color: Colors.white),
                  ),
                ),
                 // set the focused border property here
                  focusedBorder: UnderlineInputBorder(
                    borderSide: BorderSide(
                        style: BorderStyle.none, color: Colors.white),
                  ),
                ),
              ),

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