Repository: flutter
Issue: MinimumTapTargetGuideline doesn't handle elements that are scrolled beneath a pinned SliverAppBar 
Labels: framework,a: accessibility,f: scrolling,has reproducible steps,P2,customer: huggsy (g3),team-framework,triaged-framework,found in release: 3.19,found in release: 3.20

Internal bug: b/324903750


### Steps to reproduce

Please see the example code below.

### Expected results

The test passes.

### Actual results

The test fails, with an error saying that a tap target was too small.

```
$ flutter test
00:03 +0: test
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: Tappable objects should be at least Size(48.0, 48.0)
  Actual: <Instance of 'WidgetTester'>
   Which: SemanticsNode#6(Rect.fromLTRB(8.0, 36.0, 792.0, 56.0), actions: [tap], flags: [isButton,
hasEnabledState, isEnabled, isFocusable], label: "Item 0", textDirection: ltr): expected tap target
size of at least Size(48.0, 48.0), but found Size(784.0, 20.0)
          See also: https://support.google.com/accessibility/android/answer/7101858?hl=en

When the exception was thrown, this was the stack:
#0      fail (package:matcher/src/expect/expect.dart:149:31)
#1      _expect.<anonymous closure> (package:matcher/src/expect/expect.dart:125:9)
<asynchronous suspension>
<asynchronous suspension>
#8      expectLater.<anonymous closure> (package:flutter_test/src/widget_tester.dart:512:24)
<asynchronous suspension>
#9      main.<anonymous closure> (file:///Users/jiahaog/dev/flutter_scratch/test/widget_test.dart:12:7)
<asynchronous suspension>
#10     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:183:15)
<asynchronous suspension>
#11     TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1018:5)
<asynchronous suspension>
<asynchronous suspension>
(elided 7 frames from dart:async and package:stack_trace)

The test description was:
  test
════════════════════════════════════════════════════════════════════════════════════════════════════
00:03 +0 -1: test [E]
  Test failed. See exception logs above.
  The test description was: test


To run this test again: /Users/jiahaog/dev/flutter/bin/cache/dart-sdk/bin/dart test /Users/jiahaog/dev/flutter_scratch/test/widget_test.dart -p vm --plain-name 'test'
00:03 +0 -1: Some tests failed.
```


In a larger flutter app,

> Because [the root widget] create pinned app bars, other slivers in the scroll view will scroll beneath them. If a clickable widget is scrolled partially beneath it, that widget can report as having too small of a touch target size, without triggering the scroll boundary check that normally covers this edge case (no pun intended). I haven't figured out how to resolve this.


### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets('test', (WidgetTester tester) async {
    final handle = tester.ensureSemantics();
    try {
      await tester.pumpWidget(MyApp());
      await tester.pumpAndSettle();
      await tester.drag(find.byType(CustomScrollView), const Offset(0, -100));
      await tester.pumpAndSettle();
      await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
    } finally {
      handle.dispose();
    }
  });
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Tap Target Issue Demo',
        home: Scaffold(
          body: CustomScrollView(
            slivers: [
              // Pinned SliverAppBar
              const SliverAppBar(
                pinned: true,
                title: Text('Tap Target Issue Demo'),
                expandedHeight: 100.0,
              ),
              // Scrollable List
              SliverList(
                delegate: SliverChildBuilderDelegate(
                  (context, index) => Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: FilledButton(
                      onPressed: () {},
                      child: Text('Item $index'),
                    ),
                  ),
                  childCount: 100, // Generate a decent list length
                ),
              ),
            ],
          ),
        ),
      );
}
```

</details>


### Screenshots or Video

![save](https://github.com/flutter/flutter/assets/7111741/7f2ebd9d-1abf-47e8-94b7-7cf7784799ad)

This is a screenshot of the state after the test - note that all list items are of the same size and should pass the guideline check. This can also be verified by commenting out the `SilverAppBar` in the code sample above, which causes the test to pass.

See also https://github.com/flutter/flutter/issues/107615 for a related corner case which was recently fixed.

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel main, 3.20.0-13.0.pre.31, on macOS 14.3.1 23D60 darwin-x64, locale en-US)
    ! Warning: `dart` on your path resolves to /usr/local/Cellar/dart/HEAD/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/jiahaog/dev/flutter. Consider
      adding /Users/jiahaog/dev/flutter/bin to the front of your path.
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[!] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    ! CocoaPods 1.10.0 out of date (1.13.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods for instructions.
[✓] Chrome - develop for the web
[!] Android Studio (version unknown)
    ✗ Unable to determine Android Studio version.
[✓] Android Studio (version 2020.3)
[✓] Android Studio (version 4.2)
[✓] IntelliJ IDEA Community Edition (version 2022.3.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.3)
[✓] VS Code (version 1.86.2)
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 4 categories.
```

</details>