Repository navigation
AnimatedList throws 'itemIndex >= 0 && itemIndex < _itemsCount': is not true. when removing all items when an item is being removed #176362
Description
Activity
- addedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Oct 2, 2025 Reproducible using the code sample provided above.
This is likely working as intended but some documentation about the expectation would be ideal.
Labeling for further insight.
flutter doctor -v
[✓] Flutter (Channel stable, 3.35.5, on macOS 26.1 25B5042k darwin-arm64, locale en-US) [606ms] • Flutter version 3.35.5 on channel stable at /Users/deanli/dev/stable • Upstream repository https://github.com/flutter/flutter.git • Framework revision ac4e799d23 (6 days ago), 2025-09-26 12:05:09 -0700 • Engine revision d3d45dcf25 • Dart version 3.9.2 • DevTools version 2.48.0 • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-lldb-debugging [✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [6.4s] • Android SDK at /Users/deanli/Library/Android/sdk • Emulator version 36.2.10.0 (build_id 14110321) (CL:N/A) • Platform android-36.1, build-tools 36.1.0 • Java binary at: /Users/deanli/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java This is the JDK bundled with the latest Android Studio installation on this machine. To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`. • Java version OpenJDK Runtime Environment (build 21.0.8+-14018985-b1038.68) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 26.1) [1,377ms] • Xcode at /Applications/Xcode-26.1.0-beta.app/Contents/Developer • Build 17B5025f • CocoaPods version 1.16.2 [✓] Chrome - develop for the web [7ms] • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2025.1) [6ms] • Android Studio at /Users/deanli/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 21.0.8+-14018985-b1038.68) [✓] VS Code (version 1.103.2) [5ms] • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.120.0 [✓] Connected device (3 available) [7.2s] • iPhone 16 Pro Max (mobile) • 00008140-00194CC23A68801C • ios • iOS 26.1 23B5044l • macOS (desktop) • macos • darwin-arm64 • macOS 26.1 25B5042k darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 140.0.7339.214 [✓] Network resources [816ms] • All expected network resources are available. • No issues found![!] Flutter (Channel master, 3.37.0-1.0.pre-380, on macOS 26.1 25B5042k darwin-arm64, locale en-US) [3.9s] • Flutter version 3.37.0-1.0.pre-380 on channel master at /Users/deanli/dev/master ! Warning: `flutter` on your path resolves to /Users/deanli/dev/stable/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/deanli/dev/master. Consider adding /Users/deanli/dev/master/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/deanli/dev/stable/bin/dart, which is not inside your current Flutter SDK checkout at /Users/deanli/dev/master. Consider adding /Users/deanli/dev/master/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2bf5da46a5 (5 hours ago), 2025-10-02 00:24:31 -0400 • Engine revision 2bf5da46a5 • Dart version 3.10.0 (build 3.10.0-268.0.dev) • DevTools version 2.50.0 • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [1,381ms] • Android SDK at /Users/deanli/Library/Android/sdk • Emulator version 36.2.10.0 (build_id 14110321) (CL:N/A) • Platform android-36.1, build-tools 36.1.0 • Java binary at: /Users/deanli/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java This is the JDK bundled with the latest Android Studio installation on this machine. To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`. • Java version OpenJDK Runtime Environment (build 21.0.8+-14018985-b1038.68) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 26.1) [994ms] • Xcode at /Applications/Xcode-26.1.0-beta.app/Contents/Developer • Build 17B5025f • CocoaPods version 1.16.2 [✓] Chrome - develop for the web [6ms] • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Connected device (3 available) [6.2s] • iPhone 16 Pro Max (mobile) • 00008140-00194CC23A68801C • ios • iOS 26.1 23B5044l • macOS (desktop) • macos • darwin-arm64 • macOS 26.1 25B5042k darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 140.0.7339.214 [✓] Network resources [1,190ms] • All expected network resources are available. ! Doctor found issues in 1 category.- addedframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.a: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamfound in release: 3.35Found to occur in 3.35Found to occur in 3.35found in release: 3.37Found to occur in 3.37Found to occur in 3.37and removedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Oct 2, 2025 - changed the title
[-]AnimatedList items removal bug[/-][+]AnimatedList throws `'itemIndex >= 0 && itemIndex < _itemsCount': is not true.` when removing all items when an item is being removed[/+]on Oct 2, 2025 @Shunt22 I created a fix for this issue, I don't know exactly what you expected, but I believe what I proposed should handle your case.
@danagbemava-nc can you also take a look?
@Shunt22 I created a fix for this issue, I don't know exactly what you expected, but I believe what I proposed should handle your case.
@danagbemava-nc can you also take a look?
Hi @kazbeksultanov , thanks! Looks good to me!
Hi @danagbemava-nc ,
Reproducible using the code sample provided above.
This is likely working as intended but some documentation about the expectation would be ideal.
Labeling for further insight.
flutter doctor -v
In my opinion user should be able to clear the list whenever. Why should he wait for the animation to finish..?
If this was intended - there is no point in using AnimatedListView. I had to switch back to simple ListView with self-made animation.- addedP2Important issues not at the top of the work listImportant issues not at the top of the work listtriaged-frameworkTriaged by Framework teamTriaged by Framework team
on Oct 7, 2025 - added a commit that references this issue
on Oct 21, 2025 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 -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Nov 5, 2025 - addedr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
on Nov 7, 2025 - added a commit that references this issue
on Dec 10, 2025
Steps to reproduce
Is this a bug or intended behaivour?
What stops me from clearing list?
Expected results
List should be cleared without errors
Actual results
It throws an error.
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: 'package:flutter/src/widgets/animated_scroll_view.dart': Failed assertion: line 1398 pos 12: 'itemIndex >= 0 && itemIndex < _itemsCount': is not true.
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
Flutter Doctor output
Doctor output