Repository: flutter/flutter
File: packages/flutter/test/widgets/decorated_sliver_test.dart (Dart)

Code before:
  /// Regression test for https://github.com/flutter/flutter/issues/179801
  testWidgets('DecoratedSliver works with PinnedHeaderSliver overscroll', (
    WidgetTester tester,
  ) async {
    const key = Key('DecoratedSliver with border');

    await tester.pumpWidget(
      TestWidgetsApp(
        home: Align(
          alignment: Alignment.topLeft,
          child: SizedBox(
            height: 500,
            width: 300,
            child: CustomScrollView(
              physics: const BouncingScrollPhysics(),
              slivers: <Widget>[
                DecoratedSliver(
                  key: key,
                  decoration: BoxDecoration(
                    border: Border.all(strokeAlign: BorderSide.strokeAlignCenter),
                  ),
                  sliver: SliverPersistentHeader(
                    pinned: true,
                    delegate: TestDelegate(
                      stretchConfiguration: OverScrollHeaderStretchConfiguration(),
                    ),
                  ),
                ),
                const SliverToBoxAdapter(child: SizedBox(height: 1000)),
              ],
            ),
          ),
        ),
      ),
    );

    await tester.drag(find.byType(CustomScrollView), const Offset(0, 45));
    await tester.pump();

    expect(
      find.byKey(key),
      paints..something((methodName, arguments) {
        if (methodName != #drawRect) {
          return false;
        }
        final rect = arguments[0] as Rect;

        // 225.1 is the result of maxExtent (200) + the physics-diminished drag (the 45 pixels from the gesture)
        expect(rect, rectMoreOrLessEquals(const Rect.fromLTRB(0, 0, 300, 225.1), epsilon: 0.03));
        return true;
      }),

Review comment (suggestion):
@victorsanni This test should not have tested using `SliverAppBar`. I have adjusted the test accordingly.

Code after:
  });

  /// Regression test for https://github.com/flutter/flutter/issues/179801
  testWidgets('DecoratedSliver works with PinnedHeaderSliver overscroll', (
    WidgetTester tester,
  ) async {
    const key = Key('DecoratedSliver with border');

    await tester.pumpWidget(
      TestWidgetsApp(
        home: Align(
          alignment: Alignment.topLeft,
          child: SizedBox(
            height: 500,
            width: 300,
            child: CustomScrollView(
              physics: const BouncingScrollPhysics(),
              slivers: <Widget>[
                DecoratedSliver(
                  key: key,
                  decoration: BoxDecoration(
                    border: Border.all(strokeAlign: BorderSide.strokeAlignCenter),
                  ),
                  sliver: SliverPersistentHeader(
                    pinned: true,
                    delegate: TestDelegate(
                      stretchConfiguration: OverScrollHeaderStretchConfiguration(),
                    ),
                  ),
                ),
                const SliverToBoxAdapter(child: SizedBox(height: 1000)),
              ],
            ),
          ),
        ),
      ),
    );

    await tester.drag(find.byType(CustomScrollView), const Offset(0, 45));
    await tester.pump();

    expect(
      find.byKey(key),
      paints..something((methodName, arguments) {
        if (methodName != #drawRect) {
          return false;
        }
        final rect = arguments[0] as Rect;

        // 225.1 is the result of maxExtent (200) + the physics-diminished drag (the 45 pixels from the gesture)
        expect(rect, rectMoreOrLessEquals(const Rect.fromLTRB(0, 0, 300, 225.1), epsilon: 0.03));