TextField

2023-01-29  本文已影响0人  neobuger
TextField(

controller: TextEditingController.fromValue(TextEditingValue(
                  text: '${this.widget.data!["value"]}',  //判断keyword是否为空
                  // 保持光标在最后

                  selection: TextSelection.fromPosition(TextPosition(
                      affinity: TextAffinity.downstream,
                      offset: '${this.widget.data!["value"]}'.length)))),
              cursorHeight: 15,
              // textAlignVertical: TextAlignVertical.center,
              // textAlign: TextAlign.justify,
              onChanged: (text) {
                print("输入改变时" + text);

              },

              maxLines: 1,
              style: TextStyle(
                color: Color(0xff333333),

              ),
              // maxLength: 200,
              decoration: InputDecoration(
                hintText: "请输入",
                hintMaxLines: 1,
                hintStyle: TextStyle(
                  color: Color(0xff999999),

                ),
                isCollapsed: true,
                enabledBorder: new UnderlineInputBorder( // 不是焦点的时候颜色
                  borderSide: BorderSide(
                      color: Color(0x00000000)
                  ),
                ),
                focusedBorder: new UnderlineInputBorder( // 焦点集中的时候颜色
                  borderSide: BorderSide(
                      color: Color(0x00000000)
                  ),
                ),
              ),
            )
isCollapsed: true, 这个当textfield设置高度后 引起的问题有很好的效果
上一篇 下一篇

猜你喜欢

热点阅读