Skip to content

CustomScrollView applies overscroll effect on SliverAppBar #104437

@doiraduc

Description

@doiraduc

Part of #104363.

When using the new variants SliverAppBar.medium and SliverAppBar.large in a CustomScrollView, scrolling in that CustomScrollView applies the overscroll effect on the SliverAppBar itself. This behavior should not be occuring.

Expected result:

  • Scrolling through the CustomScrollView shows the overscroll effect only on the SliverList, not on the entire CustomScrollView.

Actual result:

  • Scrolling through the CustomScrollView shows the overscroll effect on the SliverAppBar too, resulting in strange behavior.
MaterialScrollBehavior.mp4
Code sample:
import 'package:flutter/material.dart';

void main() {
  runApp(const TestApp());
}

class TestApp extends StatelessWidget {
  const TestApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.from(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: Scaffold(
        body: CustomScrollView(
          slivers: [
            SliverAppBar.large(
              title: const Text('Example App'),
            ),
            SliverList(
              delegate: SliverChildBuilderDelegate(
                (context, index) {
                  return ListTile(
                    title: Text('Item ${index.toString()}'),
                  );
                },
                childCount: 20,
              ),
            )
          ],
        ),
      ),
    );
  }
}

However, when the CustomScrollView scrollBehavior is set to CupertinoScrollBehavior, this issue does not occur.

CupertinoScrollBehavior.mp4
Code sample:
import 'package:flutter/material.dart';

void main() {
  runApp(const TestApp());
}

class TestApp extends StatelessWidget {
  const TestApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData.from(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: Scaffold(
        body: CustomScrollView(
          scrollBehavior: const CupertinoScrollBehavior(),
          slivers: [
            SliverAppBar.large(
              title: const Text('Example App'),
            ),
            SliverList(
              delegate: SliverChildBuilderDelegate(
                (context, index) {
                  return ListTile(
                    title: Text('Item ${index.toString()}'),
                  );
                },
                childCount: 20,
              ),
            )
          ],
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/d: examplesSample code and demosf: material designflutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions