Repository: flutter
Issue: Unable to find elements in tests when using OverlayPortal in ListView
Labels: a: tests,framework,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.16,found in release: 3.18

### Steps to reproduce

Run the following test:
```dart
testWidgets(
  "description1",
  (tester) async {
    OverlayPortalController controller = OverlayPortalController();
    controller.show();
    await tester.pumpWidget(
      MaterialApp(
        home: Scaffold(
          body: ListView.builder(
            itemBuilder: (context, index) {
              return OverlayPortal(
                controller: controller,
                overlayChildBuilder: (context) {
                  return const Center(
                    child: Text("A"),
                  );
                },
              );
            },
            itemCount: 1,
          ),
        ),
      ),
    );
    expect(find.text('A'), findsOneWidget);
  },
);
```

### Expected results

All tests passed!

### Actual results

Test failed.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets(
    "description1",
    (tester) async {
      OverlayPortalController controller = OverlayPortalController();
      controller.show();
      await tester.pumpWidget(
        MaterialApp(
          home: Scaffold(
            body: ListView.builder(
              itemBuilder: (context, index) {
                return OverlayPortal(
                  controller: controller,
                  overlayChildBuilder: (context) {
                    return const Center(
                      child: Text("A"),
                    );
                  },
                );
              },
              itemCount: 1,
            ),
          ),
        ),
      );
      expect(find.text('A'), findsOneWidget);
    },
  );
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
00:01 +0: description1                                                                                                                                                                                                  
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: exactly one matching candidate
  Actual: _TextWidgetFinder:<Found 0 widgets with text "A": []>
   Which: means none were found but one was expected

When the exception was thrown, this was the stack:
#4      main.<anonymous closure> (file:///***/my_test/test/widget_test.dart:21:7)
<asynchronous suspension>
#5      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:183:15)
<asynchronous suspension>
#6      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1017:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

This was caught by the test expectation on the following line:
  file:///***/my_test/test/widget_test.dart line 21
The test description was:
  description1
════════════════════════════════════════════════════════════════════════════════════════════════════
00:01 +0 -1: description1 [E]                                                                                                                                                                                           
  Test failed. See exception logs above.
  The test description was: description1
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[!] Flutter (Channel [user-branch], 3.18.0-14.0.pre.46, on macOS 13.4 22F66 darwin-arm64, locale en-CN)
    ! Flutter version 3.18.0-14.0.pre.46 on channel [user-branch] at /Users/10906/source/repo/github/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    ! CocoaPods 1.11.3 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 2022.2)
[✓] VS Code (version 1.85.1)
[✓] Connected device (3 available)
[✓] Network resources

! Doctor found issues in 2 categories.
```

</details>

I understand that this is because the height of the OverlayPortal's own child is 0, and then it is excluded from the search by this code.

https://github.com/flutter/flutter/blob/8024c5e4d4fdba117a4907ccfe224900a1d468ad/packages/flutter/lib/src/widgets/sliver.dart#L1061C59-L1061C59
```dart
@override
void debugVisitOnstageChildren(ElementVisitor visitor) {
  _childElements.values.cast<Element>().where((Element child) {
    final SliverMultiBoxAdaptorParentData parentData = child.renderObject!.parentData! as SliverMultiBoxAdaptorParentData;
    final double itemExtent;
    switch (renderObject.constraints.axis) {
      case Axis.horizontal:
        itemExtent = child.renderObject!.paintBounds.width;
      case Axis.vertical:
        itemExtent = child.renderObject!.paintBounds.height;
    }

    return parentData.layoutOffset != null &&
        parentData.layoutOffset! < renderObject.constraints.scrollOffset + renderObject.constraints.remainingPaintExtent &&
        parentData.layoutOffset! + itemExtent > renderObject.constraints.scrollOffset;
  }).forEach(visitor);
}
```