我有一个TextFormField
用来输入密码,而IconButton
可以切换obscureText
。我要使按钮单击时,文本字段不会成为焦点。但是,事实并非如此。我想这与FocusNode
有关。
ValueListenableBuilder<bool>(
valueListenable: _obscureText,
builder: (context, obscureText, child) => TextFormField(
obscureText: obscureText,
decoration: InputDecoration(
suffixIcon: IconButton(
icon: Icon(obscureText ? Icons.visibility_off : Icons.visibility),
onPressed: () => _obscureText.value = !obscureText,
),
),
),
),
有人知道解决方案吗?
答案 0 :(得分:0)
您需要的只是
"internetClient",
"internetClientServer",
"privateNetworkClientServer",
"enterpriseAuthentication",
"userAccountInformation",
"picturesLibrary",
"userDataTasks",
"backgroundMediaPlayback",
"contacts",
"phoneCall",
"phoneCallHistoryPublic",
"removableStorage",
"videosLibrary",
"musicLibrary",
"userNotificationListener",
"location",
"pointOfService",
"webcam",
"microphone",
"serialcommunication"
在FocusNode.unfocus()
方法中的setState
之后调用它。
输出:
完整解决方案:
onPressed()