Skip to content

When shrinkWrap is true, the SliverAppBar is displayed below the elements of the SliverList or SliverGrid. #28197

@luoqiao6

Description

@luoqiao6

Steps to Reproduce

  1. here is the code repository to reproduce the bug.

  2. Normally, when the shrinkWrap of the CustomScrollView is false, the floating SliverAppBar will be displayed on the upper layer of the SliverList or SliverGrid as we slide the SliverList down.

  1. But, when change the value of shrinkWrap to true, the SliverAppBar is displayed below the elements of the SliverList or SliverGrid.

Why does shrinkWrap affect the display of SliverAppBar?

flutter analyze

localhost:a_custom_scroll_view_bug luoqiao$ flutter analyze
Analyzing a_custom_scroll_view_bug...                            
No issues found! (ran in 2.7s)
localhost:a_custom_scroll_view_bug luoqiao$ 

flutter doctor -v

localhost:a_custom_scroll_view_bug luoqiao$ flutter doctor -v 
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.3 18D109, locale zh-Hans-CN)
    • Flutter version 1.0.0 at /Users/luoqiao/flutter/flutter_v1.0.0-stable
    • Framework revision 5391447fae (3 months 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 28.0.3)
    • Android SDK at /Users/luoqiao/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/luoqiao/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-1024-b01)
    • 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 2.0.0
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 29.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.5)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 29.0.2
    • Dart plugin version 181.4892.1

[!] VS Code (version 1.31.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

! Doctor found issues in 1 category.
localhost:a_custom_scroll_view_bug luoqiao$ 

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      shrinkWrap: false,
      slivers: <Widget>[
        const SliverAppBar(
          pinned: false,
          floating: true,
          //expandedHeight: 250.0,
          //backgroundColor: Colors.purpleAccent,
          flexibleSpace: FlexibleSpaceBar(
            title: Text('SliverAPPBar'),
          ),
        ),
        SliverGrid.count(
          crossAxisCount: 3,
          children: [
            Padding(
              padding: EdgeInsets.only(left: 24.0, right: 24.0),
              child: Container(color: Colors.red, height: 150.0),
            ),
            Padding(
              padding: EdgeInsets.only(left: 24.0, right: 24.0),
              child: Container(color: Colors.purple, height: 150.0),
            ),
            Padding(
              padding: EdgeInsets.only(left: 24.0, right: 24.0),
              child: Container(color: Colors.green, height: 150.0),
            ),
            Padding(
              padding: EdgeInsets.only(left: 24.0, right: 24.0),
              child: Container(color: Colors.orange, height: 150.0),
            ),
            Padding(
              padding: EdgeInsets.only(left: 24.0, right: 24.0),
              child: Container(color: Colors.yellow, height: 150.0),
            ),
            Padding(
              padding: EdgeInsets.only(left: 24.0, right: 24.0),
              child: Container(color: Colors.pink, height: 150.0),
            ),
            Padding(
              padding: EdgeInsets.only(left: 24.0, right: 24.0),
              child: Container(color: Colors.cyan, height: 150.0),
            ),
            Padding(
              padding: EdgeInsets.only(left: 24.0, right: 24.0),
              child: Container(color: Colors.indigo, height: 150.0),
            ),
            Padding(
              padding: EdgeInsets.only(left: 24.0, right: 24.0),
              child: Container(color: Colors.blue, height: 150.0),
            ),
          ],
        ),
        SliverList(
          delegate: SliverChildListDelegate(
            [
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.pink, height: 100.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.cyan, height: 100.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.indigo, height: 100.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.blue, height: 100.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.yellow, height: 100.0),
              ),
            ],
          ),
        ),
        SliverFixedExtentList(
          itemExtent: 150.0,
          delegate: SliverChildListDelegate(
            [
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.red, height: 150.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.purple, height: 150.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.green, height: 150.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.orange, height: 150.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.yellow, height: 150.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.pink, height: 150.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.cyan, height: 150.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.indigo, height: 150.0),
              ),
              Padding(
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                child: Container(color: Colors.blue, height: 150.0),
              ),
            ],
          ),
        ),
      ],
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: scrollingViewports, list views, slivers, etc.found in release: 1.21Found to occur in 1.21frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions