How to add clear button to TextField Widget

后端 未结 12 1430
南笙
南笙 2020-12-22 22:11

Is there a proper way to add a clear button to the TextField?

Just like this picture from Material design guidelines:

What I found is

12条回答
  •  一生所求
    2020-12-22 23:05

            Container(
                margin: EdgeInsets.only(left: 16.0),
                child: TextFormField(
                  controller: _username,
                  decoration: InputDecoration(
                      hintText: '请输入工号',
                      filled: true,
                      prefixIcon: Icon(
                        Icons.account_box,
                        size: 28.0,
                      ),
                      suffixIcon: IconButton(
                          icon: Icon(Icons.remove),
                          onPressed: () {
                            debugPrint('222');
                          })),
                ),
              ),
    

    use iconButton

提交回复
热议问题