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

649

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,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
Share:
649
Mani murugan
Author by

Mani murugan

Updated on January 04, 2023

Comments

  • Mani murugan
    Mani murugan over 1 year

    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..

  • Mani murugan
    Mani murugan about 2 years
    Thanks for your answer. But this question is regarding accessibility usage and not normal usage. All UI controls will have single tap and double tap when accessibility is ON. System will automatically announce label name on single tap and double tap.
  • Mani murugan
    Mani murugan about 2 years
    Please read my question & previous comments clearly.