Skip to content

NestedScrollView does not allow nested scrolling when content extent is less than 2 x viewport height. #46089

@olavemil

Description

@olavemil

Steps to Reproduce

A NestedScrollView containing a CustomScrollView (or perhaps any scrolling view) with content less than twice the viewportDimension (screen height) will not permit scrolling.

One possible source for this behavior seems to be _NestedScrollPosition.updateCanDrag, which compares the totalExtent it receives (which is derived from maxScrollExtent) with viewportDimension (which has already been subtracted from the maxScrollExtent in RenderViewport.performLayout around line 1279). Replacing viewportDimension with 0.0 in updateCanDrag fixes my observed issue, but might have other side effects I'm not aware of.

Tested on 1.10.7 and master (v1.12.17-pre.67). Same behavior for debug/emulator as for release/device.

A simple example to demonstrate (though this can also be observed by using the example from the NestedScrollView documentation, by reducing the number of items from 30 to something extending just beyond the screen):

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: NestedScrollProblem()));

class NestedScrollProblem extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Scaffold(
    body: NestedScrollView(
      headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) => <Widget>[ ],
      body: SingleChildScrollView(
        child: Container(
          margin: EdgeInsets.all(8.0),
          alignment: Alignment.center,
          color: Colors.red,
          constraints: BoxConstraints.tight(MediaQuery.of(context).size + Offset(0.0, 100.0)),
          child: Text("This should be scrollable"),
        ),
      ),
    ),
  );
}

Target Platform: Android/iOS

Logs

[√] Flutter (Channel master, v1.12.17-pre.67, on Microsoft Windows [Version 10.0.18362.476], locale en-US)
    • Flutter version 1.12.17-pre.67 at C:\flutter
    • Framework revision 3ea8c87ce9 (4 hours ago), 2019-12-04 13:27:23 +0100
    • Engine revision 1cdfc99314
    • Dart version 2.7.0 (build 2.7.0-dev.2.1 2a13b1fe26)

 
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\****\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 41.1.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.40.2)
    • VS Code at C:\Users\****\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.6.0

[√] VS Code, 64-bit edition
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.6.0

[√] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

• No issues found!

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