Skip to content

NestedScrollView won't scroll using SliverOverlapAbsorber and few items (and other related bugs) #32563

@aletorrado

Description

@aletorrado

Hi! I've made a single file demo screen showing how NestedScrollView won't scroll if the amount of scroll available is less of some unknown threshold if SliverOverlapAbsorber is used as well. The widget presented next will calculate some amount of items to reproduce this issue in any screen size.

Also, AppBar doesn't seem to work in floating mode in this same condition.

Steps to Reproduce

Just render this widget:

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

class TestPage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      /*
        Using LayoutBuilder to calculate the amount of
        items to print depending on screen height
      */
      home: LayoutBuilder(
        builder: (context, box)=>Scaffold(
          body: NestedScrollView(
            headerSliverBuilder: (context, innerScrolled)=>[
              SliverOverlapAbsorber(
                handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
                child: SliverAppBar(
                  forceElevated: innerScrolled,
                  pinned: true,
                  title: Text("Printing ${(box.maxHeight/20).floor()} items"),
                ),
              ),
            ],
            body: Builder(
              builder: (context)=>CustomScrollView(
                slivers: <Widget>[
                  SliverOverlapInjector(
                    handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
                  ),
                  SliverList(
                    delegate: SliverChildListDelegate(
                      [
                        for (var i=0; i<box.maxHeight/20; i++)
                          Text("Some text $i", style: TextStyle(fontSize: 20)),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }

}

flutter doctor output

flutter doctor -v
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Linux, locale en_US)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[!] Android Studio (version 3.4)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
[!] Android Studio
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.33.1)
[✓] Connected device (1 available)

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listf: scrollingViewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onwaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions