Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Scrollbar displayed below SliverAppBar in NestedScrollView instead of having padding as high as the SliverAppBar #96061

Closed
@saibotma

Description

@saibotma

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Scroll to the end
  3. Scroll to the start and notice that the visual part of the scrollbar becomes smaller because the scrollbar moves under the sliver app bar.

Expected results:
The Scrollbar has got padding top and never overlaps with the SliverAppBar.

Actual results:
The Scrollbar gets displayed below the SliverAppBar, thus parts of it become invisible for the user.

22-01-03-15-26-08.mp4

In the screenshot below you can see, that the scrollbar gets displayed under the (in this case opaque) sliver app bar.
Screenshot_20220103-152653

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        extendBody: true,
        body: NestedScrollView(
          headerSliverBuilder: (context, _) {
            return [
              SliverAppBar(
                elevation: 0,
                title: const Text("Title"),
                backgroundColor: Colors.white.withOpacity(0.1),
                pinned: true,
                foregroundColor: Colors.black,
                flexibleSpace: const Placeholder(),
              )
            ];
          },
          body: Builder(builder: (context) {
            return MediaQuery.removePadding(
              removeTop: true,
              context: context,
              child: Scrollbar(
                isAlwaysShown: true,
                child: ListView(children: [
                  Container(height: 500, color: Colors.orange),
                  Container(height: 500, color: Colors.yellow),
                  Container(height: 10, color: Colors.brown),
                ]),
              ),
            );
          }),
        ),
      ),
    );
  }
}
Logs
[✓] Flutter (Channel stable, 2.8.1, on macOS 11.6.1 20G224 darwin-x64, locale en-DE)
    • Flutter version 2.8.1 at /Users/tobias/Documents/Dev/Tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (3 weeks ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/tobias/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Users/tobias/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7784292/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] Android Studio (version 4.2)
    • Android Studio at /Users/tobias/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/tobias/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7784292/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.3)
    • IntelliJ at /Users/tobias/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-1/212.5457.46/IntelliJ IDEA.app
    • Flutter plugin version 62.0.3
    • Dart plugin version 212.5632

[✓] VS Code (version 1.63.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • ONEPLUS A5000 (mobile) • fd788fa0 • android-arm64  • Android 10 (API 29)
    • macOS (desktop)        • macos    • darwin-x64     • macOS 11.6.1 20G224 darwin-x64
    • Chrome (web)           • chrome   • web-javascript • Google Chrome 96.0.4664.110

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: scrollingViewports, list views, slivers, etc.found in release: 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: duplicateIssue is closed as a duplicate of an existing issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions