Repository: flutter
Issue: [two_dimensional_scrollables] TapGestureRecognizer of TableSpan not working after setState()
Labels: framework,platform-web,package,a: desktop,has reproducible steps,P2,team-framework,triaged-framework,p: two_dimensional_scrollables,found in release: 3.22,found in release: 3.23

### Steps to reproduce

Tap on a row.

### Expected results

'Row $index tapped' is printed to the console.

### Actual results

onTap is not fired.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:two_dimensional_scrollables/two_dimensional_scrollables.dart';

void main() => runApp(const DemoApp());

class DemoApp extends StatelessWidget {
  const DemoApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Table View Demo App',
      home: Scaffold(
        body: InteractiveTable(),
      ),
    );
  }
}

class InteractiveTable extends StatefulWidget {
  const InteractiveTable({super.key});

  @override
  State<InteractiveTable> createState() => _InteractiveTableState();
}

class _InteractiveTableState extends State<InteractiveTable> {
  int _hoveredRow = -1;

  @override
  Widget build(BuildContext context) {
    return TableView.builder(
      rowCount: 2,
      columnCount: 2,
      columnBuilder: (index) => const TableSpan(extent: FixedSpanExtent(100)),
      rowBuilder: (index) => TableSpan(
        extent: const FixedSpanExtent(100),
        backgroundDecoration: SpanDecoration(
          color: _hoveredRow == index ? Colors.blue : Colors.white,
        ),
        onEnter: (_) => setState(() {
          _hoveredRow = index;
        }),
        onExit: (_) => setState(() {
          _hoveredRow = -1;
        }),
        recognizerFactories: <Type, GestureRecognizerFactory>{
          TapGestureRecognizer:
              GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
            () => TapGestureRecognizer(),
            (TapGestureRecognizer t) =>
                t.onTap = () => print('Row $index tapped'),
          ),
        },
      ),
      cellBuilder: (context, vicinity) {
        return TableViewCell(
          child: Text((vicinity.row * 2 + vicinity.column).toString()),
        );
      },
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
➜  bug flutter doctor -v
[!] Flutter (Channel stable, 3.19.6, on macOS 14.1.1 23B81 darwin-arm64, locale en-DE)
    • Flutter version 3.19.6 on channel stable at /library/flutter
    ! Warning: `flutter` on your path resolves to /Library/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /library/flutter. Consider adding /library/flutter/bin to
      the front of your path.
    ! Warning: `dart` on your path resolves to /Library/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /library/flutter. Consider adding /library/flutter/bin to the
      front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (6 weeks ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/ericdhom/Library/Android/sdk
    • Platform android-33, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
    • Xcode at /Applications/Xcode-beta.app/Contents/Developer
    • Build 15C5059c
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] VS Code (version 1.89.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (4 available)
    • Eric’s iPhone (mobile) • 00008020-001A2C640A63002E • ios            • iOS 17.4.1 21E236
    • iPad (mobile)          • 00008030-000C0D361E04C02E • ios            • iOS 17.4.1 21E236
    • macOS (desktop)        • macos                     • darwin-arm64   • macOS 14.1.1 23B81 darwin-arm64
    • Chrome (web)           • chrome                    • web-javascript • Google Chrome 125.0.6422.77
    ! Error: Browsing on the local area network for Apple Vision Pro. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. (code
      -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
➜  bug 
```

</details>