Skip to content

Nested ScrollBar has weird behavior #73697

Closed

Description

@kalaganov

There is ScrollBar with GridView as a child. Each GridView's child has scrollable area.

When I scrolling GridView everything is OK - the scrollbar works as intended. But If I scroll image inside any grid view item it cause ScrollBar scrolling also, it looks weird.

I think it's wrong and maybe even a bug. It shouldn't move scrollbar when I scroll something inside items.

I attached small video. Look at scrollbar's behaviour.
The same behaviour if run it on web.

the code:

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(debugShowCheckedModeBanner: false, home: Home()));

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Scaffold(body: Demo());
}

class Demo extends StatefulWidget {
  @override
  _DemoState createState() => _DemoState();
}

class _DemoState extends State<Demo> {
  ScrollController _scrollController;

  @override
  void initState() {
    super.initState();
    _scrollController = ScrollController();
  }

  @override
  Widget build(BuildContext context) {
    return Scrollbar(
      controller: _scrollController,
      isAlwaysShown: true,
      child: GridView.count(
        controller: _scrollController,
        crossAxisCount: 3,
        crossAxisSpacing: 64,
        mainAxisSpacing: 64,
        childAspectRatio: 0.5,
        padding: const EdgeInsets.only(left: 48, right: 48, top: 24, bottom: 48),
        children: List.generate(42, (i) => GridItem(i)),
      ),
    );
  }

  @override
  void dispose() {
    _scrollController.dispose();
    super.dispose();
  }
}

class GridItem extends StatelessWidget {
  GridItem(int i) : super(key: Key('$i'));

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: SizedBox(
        height: 700,
        child: Image.network('https://picsum.photos/id/81/200/300.jpg', fit: BoxFit.fill),
      ),
    );
  }
}

flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.20.3, on Mac OS X 10.15.6 19G2021, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
[!] Android Studio (version 4.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected device (1 available)
Screen.Recording.2021-01-11.at.11.17.25.mp4

Activity

  1. xu-baolin commented on Jan 11, 2021

    @xu-baolin
    Member

    Will be fixed by #71843

  2. added
    f: scrolling
    p: material_ui
    on Jan 11, 2021
  3. pedromassangocode commented on Jan 11, 2021

    @pedromassangocode

    I was able to reproduce this issue. Similar to #70771.

    flutter doctor
    [✓] Flutter (Channel master, 1.26.0-2.0.pre.251, on Mac OS X 10.15.7 19H2 darwin-x64, locale en)
        • Flutter version 1.26.0-2.0.pre.251 at /Users/pedromassango/dev/SDKs/flutter_master
        • Framework revision 5bc725bea8 (3 days ago), 2021-01-08 08:12:36 +0100
        • Engine revision 2e5833b7c5
        • Dart version 2.12.0 (build 2.12.0-179.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at /Users/pedromassango/Library/Android/sdk
        • Platform android-30, build-tools 30.0.2
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
        • All Android licenses accepted.
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.1, Build version 12A7403
        ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
            CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
            Without CocoaPods, plugins will not work on iOS or macOS.
            For more info, see https://flutter.dev/platform-plugins
          To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.1)
        • 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_242-release-1644-b3-6915495)
    
    [✓] IntelliJ IDEA Community Edition (version 2020.3.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 52.1.5
        • Dart plugin version 203.6912
    
    [✓] VS Code (version 1.52.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.18.1
    
    [✓] Connected device (4 available)
        • Redmi 5 Plus (mobile)      • 0258ff700005  • android-arm64  • Android 8.1.0 (API 27)
        • sdk gphone x86 64 (mobile) • emulator-5554 • android-x64    • Android 11 (API 30) (emulator)
        • macOS (desktop)            • macos         • darwin-x64     • Mac OS X 10.15.7 19H2 darwin-x64
        • Chrome (web)               • chrome        • web-javascript • Google Chrome 87.0.4280.88
    
    ! Doctor found issues in 1 category.
    Process finished with exit code 0
    
  4. added
    found in release: 1.26
    has reproducible steps
    on Jan 11, 2021
  5. changed the title [-]ScrollBar weird behaviour[/-] [+]Nested ScrollBar has weird behavior[/+] on Jan 11, 2021
  6. github-actions commented on Aug 7, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: scrollingfound in release: 1.26has reproducible stepsp: material_uiwaiting for PR to land (fixed)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions