Flutter:在TextFormField图标下方加下划线

时间:2019-02-04 12:55:57

标签: android dart flutter

InputDecoration未在TextFormField中的图标下方显示下划线

            TextFormField(
                          obscureText: true,
                          style: TextStyle(color: Colors.white),
                          keyboardType: TextInputType.text,
                          //validator: validatePassword,
                          decoration: InputDecoration(
                              icon: Icon(Icons.lock_outline,color: Colors.white,),
                              labelStyle: new TextStyle(color: Colors.white),
                              enabledBorder: UnderlineInputBorder(
                                  borderSide: new BorderSide(color: Colors.white)),
                              hintStyle: new TextStyle(
                                inherit: true,
                                fontSize: 18.0,
                                fontFamily: "WorkSansLight",
                                color: Colors.white,
                              ),
                              hintText: 'PASSWORD'),
                          onSaved: (String val) {

                          },
                        ),

得到这个:

enter image description here

预期:

enter image description here

1 个答案:

答案 0 :(得分:0)

使用-prefixIcon:代替icon

TextFormField(
          obscureText: true,

          style: TextStyle(color: Colors.white),
          keyboardType: TextInputType.text,
          //validator: validatePassword,
          decoration: InputDecoration(
            prefixIcon: Icon(
              Icons.lock_outline,
              color: Colors.white,
            ),
              labelStyle: new TextStyle(color: Colors.white),
              enabledBorder: UnderlineInputBorder(
                  borderSide: new BorderSide(color: Colors.white)),
              hintStyle: new TextStyle(
                inherit: true,
                fontSize: 18.0,
                fontFamily: "WorkSansLight",
                color: Colors.white,
              ),
              hintText: 'PASSWORD'),
          onSaved: (String val) {},
        ),