Repository: flutter
Issue: SliverPersistentHeaderDelegate.build overlapsContent does not work reliably
Labels: framework,f: scrolling,has reproducible steps,P2,found in release: 1.21,found in release: 2.10,customer: flex,team-framework,triaged-framework

I'm trying to add a border underneath of a sliver in a `CustomScrollView` once that sliver is pinned to the top of the scroll container, so I created a `SliverPersistentHeader`, but `overlapsContent` in my `SliverPersistentHeaderDelegate.build` method is always `false`.

After doing some digging, I think this issue can be reliably reproduced on any `SliverPersistentHeader` that is the FIRST `SliverPersistentHeader` in a `CustomScrollView`.

For example, let's work with the collapsible scrolling list demonstrated at the end of this article: https://medium.com/flutter-io/slivers-demystified-6ff68ab0296f#bde5. Let's modify the `_SliverAppBarDelegate.build` method as such:

```dart
Widget build(
  BuildContext context,
  double shrinkOffset,
  bool overlapsContent,
) {
  return SizedBox.expand(
    child: Container(
      color: overlapsContent ? Colors.red : Colors.lightBlue,
      child: child,
    ),
  );
}
```

And let's update `makeHeader` as such:

```dart
SliverPersistentHeader makeHeader(String headerText) {
  return SliverPersistentHeader(
    pinned: true,
    delegate: _SliverAppBarDelegate(
      minHeight: 60,
      maxHeight: 200,
      child: Center(child: Text(headerText)),
    ),
  );
}
```

These changes should make it so when a header becomes pinned, its background turns from blue to red. If you actually test this out, this change works for all of the headers EXCEPT for the first one.

```
❯ flutter doctor -v
[✓] Flutter (Channel beta, v1.0.0, on Mac OS X 10.14.2 18C54, locale en-US)
    • Flutter version 1.0.0 at /Users/maxlapides/flutter
    • Framework revision 5391447fae (7 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/maxlapides/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • ANDROID_HOME = /Users/maxlapides/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.4
    • CocoaPods version 1.6.0.beta.1

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] VS Code (version 1.30.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.21.1

[✓] Connected device (2 available)
    • Max's iPhone • 65760f04a8cdf8dc55bf798b8cf0ab5cf488674c • ios • iOS 12.1.2
    • iPhone XS    • 9CFC4B23-BE03-4DC9-B1CD-5E1226F5A183     • ios • iOS 12.1 (simulator)

• No issues found!
```