Repository: flutter
Issue: Needs layout assertion is failed during hit test for SlideTransition + CustomScrollView with shrinkWrap
Labels: c: crash,framework,f: scrolling,a: error message,has reproducible steps,P2,found in release: 3.0,team-framework,triaged-framework,found in release: 3.13,found in release: 3.16

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

1. Run this example https://github.com/MbIXjkee/slide_shrink_exception on a Mac desktop (other platforms are affected as well, but on Mac, it is 100% times reproducible)
2. Make a scroll

### Expected results

There are no exceptions thrown

### Actual results

'package:flutter/src/rendering/proxy_box.dart': Failed assertion: line 2935 pos 12:
'!debugNeedsLayout': is not true.

### Code sample

<details><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() => runApp(const DemoApp());

class DemoApp extends StatelessWidget {
  const DemoApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: _TestPage(),
    );
  }
}

class _TestPage extends StatefulWidget {
  const _TestPage();

  @override
  State<_TestPage> createState() => _TestPageState();
}

class _TestPageState extends State<_TestPage> with SingleTickerProviderStateMixin {
  final _list = List.generate(30, (index) => index);
  late final AnimationController _controller;
  late final Animation<Offset> _animation;

  @override
  void initState() {
    super.initState();

    _controller = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 300),
    );
    _animation = Tween<Offset>(
      begin: Offset.zero,
      end: Offset.zero,
    ).animate(_controller);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SlideTransition(
        position: _animation,
        child: CustomScrollView(
          shrinkWrap: true,
          physics: const ClampingScrollPhysics(),
          slivers: _list
              .map(
                (index) => SliverToBoxAdapter(
                  child: Container(
                    color: index.isEven ? Colors.green : Colors.red,
                    height: 100,
                    width: double.infinity,
                    child: Text('$index'),
                  ),
                ),
              )
              .toList(),
        ),
      ),
    );
  }
}

```

</details>


### Screenshots or Video

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


### Logs

<details><summary>Logs</summary>

```console
══╡ EXCEPTION CAUGHT BY GESTURES LIBRARY ╞══════════════════════════════════════════════════════════
The following assertion was thrown while handling a pointer data packet:
'package:flutter/src/rendering/proxy_box.dart': Failed assertion: line 2935 pos 12:
'!debugNeedsLayout': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

When the exception was thrown, this was the stack:
#2      RenderFractionalTranslation.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:2935:12)
proxy_box.dart:2935
#3      RenderFractionalTranslation.hitTest (package:flutter/src/rendering/proxy_box.dart:2922:12)
proxy_box.dart:2922
#4      RenderBoxContainerDefaultsMixin.defaultHitTestChildren.<anonymous closure> (package:flutter/src/rendering/box.dart:2854:25)
box.dart:2854
#5      BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:800:31)
box.dart:800
#6      RenderBoxContainerDefaultsMixin.defaultHitTestChildren (package:flutter/src/rendering/box.dart:2849:33)
box.dart:2849
#7      RenderCustomMultiChildLayoutBox.hitTestChildren (package:flutter/src/rendering/custom_layout.dart:415:12)
custom_layout.dart:415
#8      RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
box.dart:2475
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.9, on macOS 13.5.1 22G90 darwin-arm64, locale en-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    ✗ Unable to get list of installed Simulator runtimes.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Community Edition (version 2023.2.1)
[✓] VS Code (version 1.84.2)
[✓] Connected device (3 available)
[✓] Network resources
```

</details>