'Flutter Semantics Reads button title on both single tap and double tap

I have a tooltip in my UI which has semantics label "Tooltip to know about your number". Below is the code snippet for the same.

Semantics(
                              
                              label: 'Tooltip to know about your number',
                              child: InkWell(
                                child: Image.asset('images/info_selected.png'),
                                onTap: (){
                                  //some action top show tooltip
                                },
                              ),
                            ),

When accessibility is ON , and I single tap on info Inkwell, it announce "Tooltip to know about your number" as expected. But my issue here , Its also announcing the same when I double tap.. It should only do the functionality which I wrote inside onTap function when I double tap. What is the best way to make it like , it should not announce when I double tap?

Same code is working fine in android and it announce only when I single tap.. only iOS screen reader is announcing the label on both single tap and double tap..

Same issue when I use Gesture Detector or Button instead of InkWell..



Solution 1:[1]

Inkwell have a onTap and onDoubleTap both functions available

Reference - https://api.flutter.dev/flutter/material/InkWell-class.html

Output :-

enter image description here

Code :-

import 'package:flutter/material.dart';

class InkwellExample extends StatefulWidget {
  const InkwellExample({Key? key}) : super(key: key);

  @override
  State<InkwellExample> createState() => _InkwellExampleState();
}

class _InkwellExampleState extends State<InkwellExample> {
  String taps = "";

  @override
  Widget build(BuildContext context) {
    final Size size = MediaQuery.of(context).size;
    return Scaffold(
      body: SizedBox(
        width: size.width,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            InkWell(
              child: const Icon(Icons.info),
              onTap: () => setState(() {
                taps = "TAP";
              }),
              onDoubleTap: () => setState(() {
                taps = "Double TAP";
              }),
            ),
            Text(
              taps == "" ? "" : taps,
              style: const TextStyle(
                fontSize: 24.0,
                fontWeight: FontWeight.bold,
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Solution 2:[2]

To keep screen readers from reading anything other than what you have in your label parameter, add excludeSemantics: true. So your code would look like this:

Semantics(
  label: 'Tooltip to know about your number',
  excludeSemantics: true,
  child: InkWell(
    child: Image.asset('images/info_selected.png'),
    onTap: (){
      //some action top show tooltip
    },
  ),
),

Another parameter which may be of interest is onTapHint.

One reference I've used: https://www.woolha.com/tutorials/flutter-using-semantics-mergesemantics-examples

Sources

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

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Jared Fields