在我的应用程序中,我们在文本字段的末尾有一个清除图标。
启用 VoiceOver 后,无法激活“清除”图标,因为焦点仅允许导航到输入字段。没有voiceOver它工作正常。我们已将此 closeIcon 添加到文本字段 SuffixIcon。(它必须像这样)。任何人都请帮助我 closeIcon 将如何与 VoiceOver 一起使用。
代码:
孩子:
TextField(
key: widget.inputKey,
textInputAction: widget.textInputAction,
onEditingComplete: widget.onEditCompleted,
style: style.inputStyle.textStyle,
decoration: InputDecoration(
isDense: true,
hintText: widget.hint,
errorStyle: style.errorStyle.textStyle,
hintStyle: style.hintStyle.textStyle,
prefixStyle: style.prefixStyle.textStyle,
suffixStyle: style.suffixStyle.textStyle,
counterStyle: style.counterStyle.textStyle,
suffixIconConstraints: context.theme.getIconStyle(formInputPrefixIconStyleId).constraints,
suffixIcon: _suffixIcon(context),
prefixIconConstraints: const BoxConstraints(minWidth: 8, minHeight: 8),
prefixIcon: widget.textFieldPrefix != null ? _fieldPrefix(style) : null,
border: _getBorderStyle(style),
focusedBorder: _getFocusedBorderStyle(style),
enabledBorder: _getEnabledBorderStyle(style),
),
onChanged: (text) {
setState(() {
_shouldShowClearIcon = text.isNotEmpty;
});
widget.onChanged.call(text);
},
focusNode: widget.focusNode,
controller: widget.controller,
showCursor: true,
keyboardAppearance: style.keyboardAppearance,
),
),
),
Visibility(
visible: _hasError(),
child: AppFieldError(
key: const Key('bottomErrorContainer'),
errorText: widget.alertMessage,
style: context.theme
.getContainerStyle(widget.showWarning ? formWarningContainerStyleId : formErrorContainerStyleId),
),
),
],
),
));
}
Widget _suffixIcon(BuildContext context) {
if (widget.hasShowSuccess) {
return _successIcon(context);
}
if (_shouldShowClearIcon && widget.isEnabled) {
return _clearIcon(context);
}
return null;
}