demo涵蓋內(nèi)容如下圖
two.gif
three.gif
TextField(
obscureText: this.isShowEye,
onChanged: (value) {
setState(() {
this.inputValue = value;
});
},
inputFormatters: [
// 白名單
FilteringTextInputFormatter.allow(RegExp('^[0-9]*\$')),
// 黑名單
FilteringTextInputFormatter.deny(RegExp("[a-z]")),
],
decoration: InputDecoration(
// 垂直居中
contentPadding: EdgeInsets.symmetric(vertical: 0),
prefixIcon: Icon(Icons.search), //左邊圖標
suffixIcon: IconButton( // 右邊圖標
onPressed: () {
setState(() {
this.isShowEye = !this.isShowEye;
});
},
icon:
Icon(this.isShowEye ? Icons.remove_red_eye : Icons.close),
),
hintText: "請輸入",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
width: 0.5,
color: Colors.amber,
),
),
),
),