Skip to content

ReorderableListView#onReorder passes an unexpected new index #24786

@chrislambe

Description

@chrislambe

The ReorderableListView widget seems to passing an incorrect newIndex parameter when triggering the onReorder handler.

Steps to Reproduce

Here's a demo of the behavior as described in the below steps:
https://gist.github.com/chrislambe/b9aa44a5f3d3cc7dc6fdb24fb221982d

  1. Create an app with a ReorderableListView widget and dummy data.
  2. In the onReorder handler, print out the new index.
  3. Drag the item in the 0 index position down until it swaps positions with the item in 1 index then, without releasing the item, drag it back to its original position and release. Note that the printed new index is 1 instead of 0, even though the intent was to drop the item in its original position.
  4. Drag the item to the bottom of the list and release. Note that the new index is 1 greater than the bounds of the children List.

Logs

Result of above step 3

flutter: oldIndex: 0, newIndex: 1, length: 4

Result of above step 4

flutter: oldIndex: 0, newIndex: 4, length: 4

flutter analyze

$ flutter analyze
Analyzing on_reorder_broken...
No issues found! (ran in 2.3s)

flutter doctor -v

$ flutter doctor -v
[✓] Flutter (Channel dev, v0.11.9, on Mac OS X 10.14.1 18B75, locale en-US)
    • Flutter version 0.11.9 at /Applications/flutter
    • Framework revision d48e6e433c (7 days ago), 2018-11-20 22:05:23 -0500
    • Engine revision 5c8147450d
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/chris/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
    • All Android licenses accepted.

[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    ✗ Verify that all connected devices have been paired with this computer in Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
      To update with Brew, run:
        brew update
        brew uninstall --ignore-dependencies libimobiledevice
        brew uninstall --ignore-dependencies usbmuxd
        brew install --HEAD usbmuxd
        brew unlink usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    • ios-deploy 1.9.2
    ✗ ios-deploy out of date (1.9.4 is required). To upgrade with Brew:
        brew upgrade ios-deploy
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 23.2.1
    • Dart plugin version 171.4424
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)

[✓] VS Code (version 1.29.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.20.0

[✓] Connected device (2 available)
    • moto x4   • ZY224KS2L3                           • android-arm64 • Android 8.1.0 (API 27)
    • iPhone XR • F2133438-AFB5-421D-9CC0-36FD9FE97D28 • ios           • iOS 12.1 (simulator)

! Doctor found issues in 1 category.

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: qualityA truly polished experiencec: API breakBackwards-incompatible API changescustomer: crowdAffects or could affect many people, though not necessarily a specific customer.f: material designflutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.found in release: 1.26Found to occur in 1.26frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions