'flutter- Button to clear the field contents on text Field is not read out by the voice over nor it is functioning when voice over is switched ON

In my application We have a Clear icon at the end of the Textfield.

When VoiceOver enabled the 'Clear' icon cannot be activated, as the focus only allows navigation into the input field. Without voiceOver it is working fine. We have added this closeIcon to textfield SuffixIcon. (It must like this). Anyone please help me how closeIcon will work with voiceOver.

code:

child:

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;
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source