-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Dismissible animation resets when listView is being rebuilt #130661
Copy link
Copy link
Closed
Labels
r: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issue
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Dismiss an item.
- Drag to dismiss a second item while the first one is still animating.
- When the first item is removed from the list, the drag position of the second item is reset.
Expected results
The dismissible widget should keep it's current state when another is successfully dismissed:
- Drag position.
- Waiting for
onConfirmfunction. - Resize animation.
Actual results
When the first item is removed from the list, the drag position and the resize animation of the second item are reset.
Code sample
Code sample
Since this issue can be reproduce in the official Dart pad.
Don't forget to call setState(() {}) to rebuild the list.
List<int> items = List<int>.generate(100, (int index) => index);
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: items.length,
padding: const EdgeInsets.symmetric(vertical: 16),
itemBuilder: (BuildContext context, int index) {
return Dismissible(
background: Container(
color: Colors.green,
),
key: ValueKey<int>(items[index]),
onDismissed: (DismissDirection direction) {
setState(() {
items.removeAt(index);
});
},
child: ListTile(
title: Text(
'Item ${items[index]}',
),
),
);
},
);
}Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [version 10.0.22621.1992], locale fr-FR)
• Flutter version 3.10.5 on channel stable at C:\Users\Martin\Documents\flutter_windows_2.10.3-stable\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 796c8ef792 (5 weeks ago), 2023-06-13 15:51:02 -0700
• Engine revision 45f6e00911
• Dart version 3.0.5
• DevTools version 2.23.1
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc2)
• Android SDK at C:\Users\Martin\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.0-rc2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.2)
• 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 11.0.12+7-b1504.28-7817840)
[√] IntelliJ IDEA Community Edition (version 2020.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.1.1
• 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.80.0)
• VS Code at C:\Users\Martin\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (4 available)
• SM G990B (mobile) • RFCRC1M1TPR • android-arm64 • Android 13 (API 33)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [version 10.0.22621.1992]
• Chrome (web) • chrome • web-javascript • Google Chrome 110.0.5481.177
• Edge (web) • edge • web-javascript • Microsoft Edge 112.0.1722.68
[√] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.
Process finished with exit code 0Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
r: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issue