文本格式字段中的内联平面按钮

时间:2019-11-15 09:53:54

标签: flutter dart flutter-layout

enter image description here

尝试在textform字段中添加平面按钮,以下是当前字段实现的代码,

NULL

有人可以按照上面的屏幕快照协助添加它。

2 个答案:

答案 0 :(得分:0)

只需在suffixIcon实现中添加InputDecoration属性,然后将FlatButton小部件传递给它即可。下面的示例代码:

decoration: InputDecoration(
                  icon: Icon(Icons.help, color: Colors.black, ),
//                        contentPadding: EdgeInsets.fromLTRB(20, 20, 20, 20),
                  labelText: 'Enter your password',
                  labelStyle: TextStyle(color: Colors.black),
                  focusedBorder: UnderlineInputBorder(
                      borderSide: BorderSide(color: Colors.black)),
                  enabledBorder: UnderlineInputBorder(
                      borderSide: BorderSide(color: Colors.black)),
                    suffixIcon: FlatButton(
                      child: Text('Need Help?'),
                      onPressed: () {},
                    )
                ),

enter image description here

答案 1 :(得分:0)

尽管@Drashan答案是正确的,但是如果有人只在重点关注时需要显示“需要帮助”,请尝试

         TextFormField(
            controller: messageController,
            decoration: InputDecoration(
              labelText: 'Message*',
                suffix: InkWell(onTap:(){},child: Text('Need Help?',style: 
                TextStyle(color: Colors.black,fontSize: 14),)),
            ),
            keyboardType: TextInputType.multiline,
          ),

关注

enter image description here

不专心

enter image description here