Repository: flutter
Issue: [a11y] TalkBack sends tap to wrong target when InkWell excludes semantics
Labels: platform-android,a: accessibility,f: focus,has reproducible steps,P2,team-android,triaged-android,found in release: 3.19,found in release: 3.22

### Steps to reproduce

We use an `InkWell` as a parent container for a set of individually tappable child widgets so that the accessibility focus of the `InkWell` surrounds all the child widgets, whilst still allowing interaction with each child to receive accessibility focus individually.

On Android when the `InkWell` has accessibility focus and `excludeSemantics: true` then the `onTap` is called correctly.  However, on Android, when the `InkWell` has `excludeSemantics: false` the tap event is instead sent to a child widget.  This works correctly on iOS with VoiceOver.

The problem has been observed with different tappable child widgets, such as `FilterChip` and `ElevatedButton`.

The example below is a simplified version that demonstrates this.  The "Some title" text widget is inside the parent `InkWell`, as are three `ElevatedButton` widgets.  When the `InkWell` has accessibility focus and TalkBack is enabled, double-tapping the screen should trigger the `onTap` method, however, it instead triggers `onPressed` callback of one of the button widgets.

### Expected results

The same behaviour as on VoiceOver.  When the `InkWell` has accessibility focus and the TalkBack user double-taps the screen, then the InkWell's onTap callback should be called.  The button's onPressed should only be called if the button has accessibility focus.

### Actual results

I've observed that a different button can receive the InkWell's tap event depending on whether the buttons are contained in a `Row`, `Column` or `Wrap`.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Bug Demo',
      theme: ThemeData.light(),
      darkTheme: ThemeData.dark(),
      home: const HomePage(title: 'Bug Demo'),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key, required this.title});

  final String title;

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  String _msg = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            InkWell(
              excludeFromSemantics: true,
              onTap: () {
                setState(() => _msg = 'Tapped "filter chips".');
                SemanticsService.announce(_msg, Directionality.of(context));
              },
              child: Column(
                children: [
                  const Text(
                    'Some title',
                    style: TextStyle(fontSize: 20),
                    textAlign: TextAlign.center,
                  ),
                  const SizedBox(height: 20),
                  ...List.generate(
                    3,
                    (index) => ElevatedButton(
                      child: Text('Button $index'),
                      onPressed: () {
                        setState(() => _msg = 'Tapped button $index.');
                        SemanticsService.announce(
                          _msg,
                          Directionality.of(context),
                        );
                      },
                    ),
                  ),
                ],
              ),
            ),
            const SizedBox(height: 20),
            Text(_msg, style: const TextStyle(fontSize: 20)),
          ],
        ),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

_No response_

### Logs

_No response_

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.1)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!
```

</details>