Skip to content

ListWheelScrollView doesn't scroll to last item when items are removed #90953

Closed

Description

@nt4f04uNd

Steps to Reproduce

  1. Have a ListWheelScrollView
  2. Remove some items

Expected results: list behaves like a regular ListView

Actual results: list stucks until you scroll aggressively

Video
2021-09-29.15-05-46.mp4
Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: MyHomePage(),
  ));
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key}) : super(key: key);

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

class _MyHomePageState extends State<MyHomePage> {
  final list = [0, 1, 2, 3, 4, 5];
  final colors = [
    Colors.cyan,
    Colors.indigo,
    Colors.pink,
    Colors.red,
    Colors.blue,
    Colors.yellowAccent
  ];

  @override
  void initState() {
    super.initState();
  }

  Future<void> removeItems() async {
    if (list.length <= 3)
      return;
    list.removeLast();
    list.removeLast();
    list.removeLast();
    setState(() { });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Row(
          children: [
            ElevatedButton(
              child: Text('remove items'),
              onPressed: removeItems,
            ),
          ],
        ),
      ),
      body: ListWheelScrollView(
        itemExtent: 400,
        physics: FixedExtentScrollPhysics(),
        children: [
          for (final index in list)
            SizedBox(
              width: double.infinity,
              child: Container(
                height: 400,
                color: colors[index % 6],
                child: Text(
                  index.toString(),
                  style: TextStyle(
                    fontSize: 30,
                  ),
                ),
              ),
            ),
        ],
      ),
    );
  }
}
flutter doctor -v
[√] Flutter (Channel master, 2.6.0-12.0.pre.136, on Microsoft Windows [Version 10.0.19041.1237], locale ru-RU)
    • Flutter version 2.6.0-12.0.pre.136 at C:\dev\src\flutter
    • Upstream repository [email protected]:nt4f04und/flutter.git
    • FLUTTER_GIT_URL = [email protected]:nt4f04und/flutter.git
    • Framework revision aaa14b8004 (2 hours ago), 2021-09-29 06:03:04 -0400
    • Engine revision bccb3a57eb
    • Dart version 2.15.0 (build 2.15.0-156.0.dev)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\danya\AppData\Local\Android\sdk
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.7.30621.155
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 4.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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-b01)

[√] IntelliJ IDEA Community Edition (version 2020.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.3.3
    • 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

[√] VS Code (version 1.60.2)
    • VS Code at C:\Users\danya\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.26.0

[√] Connected device (4 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.19041.1237]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 94.0.4606.61
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 94.0.992.31

! Doctor found issues in 1 category.

Activity

  1. danagbemava-nc commented on Sep 29, 2021

    @danagbemava-nc
    Member

    Hi @nt4f04uNd, this looks like it might be an issue with emulators/simulator, can you check if you're able to reproduce it on a real device?

    Thank you

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 29, 2021
  3. Shashwat2708 commented on Sep 29, 2021

    @Shashwat2708

    @nt4f04uNd first just restart everything. It honestly helps more than you would expect. If the issue is still not fixed, just either update the flutter sdk or use another emulator. It will work fine.

  4. nt4f04uNd commented on Sep 29, 2021

    @nt4f04uNd
    MemberAuthor

    Hi @danagbemava-nc, it's reproducible on the Redmi Note 5 and in the dartpad

  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 29, 2021
  6. danagbemava-nc commented on Sep 30, 2021

    @danagbemava-nc
    Member

    Issue is reproducible on stable and master.

    When using a ListView, the list scrolls to the last item when items are removed, however, that is not the case when using a ListWheelScrollView. The user has to manually scroll before the items can be accessed. See attached videos

    flutter doctor -v
    [✓] Flutter (Channel stable, 2.5.1, on macOS 11.5.1 20G80 darwin-arm, locale en-GB)
        • Flutter version 2.5.1 at /Users/nexus/dev/sdks/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision ffb2ecea52 (13 days ago), 2021-09-17 15:26:33 -0400
        • Engine revision b3af521a05
        • Dart version 2.14.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.5.1, Build version 12E507
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2020.3)
        • 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 11.0.10+0-b96-7249189)
    
    [✓] VS Code (version 1.60.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.26.0
    
    [✓] Connected device (3 available)
        • M2007J20CG (mobile) • 5dd3be00 • android-arm64  • Android 11 (API 30)
        • macOS (desktop)     • macos    • darwin-arm64   • macOS 11.5.1 20G80 darwin-arm
        • Chrome (web)        • chrome   • web-javascript • Google Chrome 94.0.4606.61
    
    • No issues found!
    [✓] Flutter (Channel master, 2.6.0-12.0.pre.150, on macOS 11.5.1 20G80 darwin-arm, locale en-GB)
        • Flutter version 2.6.0-12.0.pre.150 at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 367531447c (10 hours ago), 2021-09-29 20:03:04 -0400
        • Engine revision 9224a17d1c
        • Dart version 2.15.0 (build 2.15.0-162.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 12.5.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 2020.3)
        • 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 11.0.10+0-b96-7249189)
    
    [✓] VS Code (version 1.60.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.26.0
    
    [✓] Connected device (3 available)
        • M2007J20CG (mobile) • 5dd3be00 • android-arm64  • Android 11 (API 30)
        • macOS (desktop)     • macos    • darwin-arm64   • macOS 11.5.1 20G80 darwin-arm
        • Chrome (web)        • chrome   • web-javascript • Google Chrome 94.0.4606.61
    
    • No issues found!
    videos

    ListView

    telegram-cloud-document-4-5958415439775139945.mp4

    ListWheelScrollView

    telegram-cloud-document-4-5958415439775139946.mp4
  7. added
    f: scrollingViewports, list views, slivers, etc.
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Sep 30, 2021
  8. changed the title [-]ListWheelScrollView stucks blank when removing items[/-] [+]ListWheelScrollView doesn't scroll to last item when items are removed[/+] on Sep 30, 2021
  9. self-assigned this
    on Jan 4, 2022
  10. github-actions commented on Jan 26, 2022

    @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.

  11. locked as resolved and limited conversation to collaborators on Jan 26, 2022
  12. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

f: scrollingViewports, list views, slivers, etc.found in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/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