Repository navigation
ReorderableListView throws errors when containing only one draggable item #136331
Copy link
Copy link
Closed
Closed
Copy link
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
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
- Create Column
- Create Flexible Widget as child
- Create ReorderableListView as child
- Set shrinkWrap of ReorderableListView to true
- Set onReorder
- Set Children as ReorderableDragStartListener
- Start run & debug on mobile android emulator (tested with Pixel 6 Pro API 29 and 34)
- Observe that if one item gets added to the list, then dragged over the space / area of the shrinked ReorderableListView, errors get thrown around
Expected results
Even if one item gets added to ReorderableListView with shrinkWrap set to true, the calculation of the area for reordering should still work, without throwing errors. It seems like shirnkWrap isn't working right.
Actual results
Logs
E/flutter ( 5496): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/scrollable_helpers.dart': Failed assertion: line 242 pos 7: 'globalRect.size.width >= _dragTargetRelatedToScrollOrigin.size.width &&
scrollable_helpers.dart:242
E/flutter ( 5496): globalRect.size.height >= _dragTargetRelatedToScrollOrigin.size.height': Drag target size is larger than scrollable size, which may cause bouncing
E/flutter ( 5496): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
E/flutter ( 5496): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
E/flutter ( 5496): #2 EdgeDraggingAutoScroller._scroll
scrollable_helpers.dart:242
E/flutter ( 5496): #3 EdgeDraggingAutoScroller.startAutoScrollIfNecessary
scrollable_helpers.dart:227
E/flutter ( 5496): #4 SliverReorderableListState._dragUpdate.<anonymous closure>
reorderable_list.dart:747
E/flutter ( 5496): #5 State.setState
framework.dart:1139
E/flutter ( 5496): #6 SliverReorderableListState._dragUpdate
reorderable_list.dart:744
E/flutter ( 5496): #7 _DragInfo.update
reorderable_list.dart:1275
E/flutter ( 5496): #8 MultiDragPointerState._startDrag
multidrag.dart:145
E/flutter ( 5496): #9 MultiDragGestureRecognizer._startDrag
multidrag.dart:293
E/flutter ( 5496): #10 MultiDragGestureRecognizer.acceptGesture.<anonymous closure>
multidrag.dart:281
E/flutter ( 5496): #11 _ImmediatePointerState.accepted
multidrag.dart:343
E/flutter ( 5496): #12 MultiDragGestureRecognizer.acceptGesture
multidrag.dart:281
E/flutter ( 5496): #13 GestureArenaManager._resolveInFavorOf
arena.dart:281
E/flutter ( 5496): #14 GestureArenaManager._resolve
arena.dart:239
E/flutter ( 5496): #15 GestureArenaEntry.resolve
arena.dart:53
E/flutter ( 5496): #16 MultiDragPointerState.resolve
multidrag.dart:81
E/flutter ( 5496): #17 _ImmediatePointerState.checkForResolutionAfterMove
multidrag.dart:337
E/flutter ( 5496): #18 MultiDragPointerState._move
multidrag.dart:101
E/flutter ( 5496): #19 MultiDragGestureRecognizer._handleEvent
multidrag.dart:254
E/flutter ( 5496): #20 PointerRouter._dispatch
pointer_router.dart:98
E/flutter ( 5496): #21 PointerRouter._dispatchEventToRoutes.<anonymous closure>
pointer_router.dart:143
E/flutter ( 5496): #22 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
E/flutter ( 5496): #23 PointerRouter._dispatchEventToRoutes
pointer_router.dart:141
E/flutter ( 5496): #24 PointerRouter.route
pointer_router.dart:127
E/flutter ( 5496): #25 GestureBinding.handleEvent
binding.dart:465
E/flutter ( 5496): #26 GestureBinding.dispatchEvent
binding.dart:445
E/flutter ( 5496): #27 RendererBinding.dispatchEvent
binding.dart:331
E/flutter ( 5496): #28 GestureBinding._handlePointerEventImmediately
binding.dart:400
E/flutter ( 5496): #29 GestureBinding.handlePointerEvent
binding.dart:363
E/flutter ( 5496): #30 GestureBinding._flushPointerEventQueue
binding.dart:320
E/flutter ( 5496): #31 GestureBinding._handlePointerDataPacket
binding.dart:293
E/flutter ( 5496): #32 _invoke1 (dart:ui/hooks.dart:158:13)
E/flutter ( 5496): #33 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:382:7)
E/flutter ( 5496): #34 _dispatchPointerDataPacket (dart:ui/hooks.dart:91:31)
Code sample
Minimal code sample to use in "run & debug" mode. Check output in debug console.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final List<String> _selectedOrganizations = ["Org 1"];
final List<String> _unselectedOrganizations = ["Org 2", "Org 3"];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Reorderable List Example")),
body: Column(
children: [
Flexible(
flex: 1,
child: ReorderableListView(
shrinkWrap: true,
onReorder: (int oldIndex, int newIndex) {
setState(() {
if (newIndex > oldIndex) {
newIndex -= 1;
}
final item = _selectedOrganizations.removeAt(oldIndex);
_selectedOrganizations.insert(newIndex, item);
});
},
children: [
for (int index = 0;
index < _selectedOrganizations.length;
index++)
ReorderableDragStartListener(
index: index,
key: ValueKey(_selectedOrganizations[index]),
child: Card(
child: ListTile(
leading: buildOrganizationImage(
_selectedOrganizations[index], const CircleAvatar()),
title: Text(_selectedOrganizations[index]),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.delete_rounded,
color: Colors.red),
onPressed: () {
setState(() {
final organization =
_selectedOrganizations[index];
_selectedOrganizations.removeAt(index);
_unselectedOrganizations.add(organization);
});
},
),
Icon(Icons.drag_handle,
color: Theme.of(context).primaryColor),
],
),
),
),
),
],
),
),
],
),
);
}
Widget buildOrganizationImage(String organization, CircleAvatar avatar) {
// Placeholder
return avatar;
}
}Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.10.2, on Microsoft Windows [Version 10.0.22621.2283], locale de-DE)
• Flutter version 3.10.2 on channel stable at C:\Flutter\Installation\flutter_windows_3.10.2-stable\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 9cd3d0d9ff (5 months ago), 2023-05-23 20:57:28 -0700
• Engine revision 90fa3ae28f
• Dart version 3.0.2
• 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.2)
• Android SDK at C:\Users\TuragNikandamCanvasR\AppData\Local\Android\sdk
• Platform android-34, build-tools 33.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Professional 2022 17.6.3)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Professional
• Visual Studio Professional 2022 version 17.6.33801.468
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2022.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 17.0.6+0-b2043.56-9586694)
[√] VS Code (version 1.83.0)
• VS Code at C:\Users\TuragNikandamCanvasR\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.74.0
[√] Connected device (5 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 14 (API 34) (emulator)
• Android SDK built for x86 (mobile) • emulator-5556 • android-x86 • Android 10 (API 29) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.2283]
• Chrome (web) • chrome • web-javascript • Google Chrome 117.0.5938.150
• Edge (web) • edge • web-javascript • Microsoft Edge 117.0.2045.60
[√] Network resources
• All expected network resources are available.
• No issues found!Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Activity
dam-ease commentedon Oct 11, 2023
Hi @TuragNikandam. Thanks for filing this. I can reproduce this on the latest
masterandstablechannels. I see this is peculiar toAndroidas I'm unable to reproduce this oniOS.stable, master flutter doctor -v
[-]ReorderableListView throws errors when containing only one dragable item[/-][+]ReorderableListView throws errors when containing only one draggable item[/+]MeatCheatDev commentedon Dec 20, 2023
I am encountering the same issue as described in #136331. The exception occurs when interacting with an Image widget in a Flutter web application. My widget tree:
-Material app
--SelectionArea
---Scaffold
----PageView
-----Stack
------This:
The exception is thrown as soon as the image is interacted with, e.g. simply by clicking on it.
I have attempted to mitigate the issue by using IgnorePointer and adjusting the AspectRatio, but these attempts have not resolved the error. It appears to be a persistent issue, also in the Flutter web environment.
Best Regards.
xSILENCEx commentedon Dec 31, 2023
Platform windows has the same problem
2 remaining items
gxsham commentedon Aug 26, 2024
Considering this happens because you have only one element, and (it makes sense) you cannot reorder one element, I am checking the size of my list and setting enabled to false:
ReorderableSliverList( enabled: myList.length > 1, ... )26sameer commentedon Dec 18, 2024
Quick Fix (Only for list items without interactions):
You can wrap the ReorderableListView with the AbsorbPointer widget and set absorbing (bool) to:
absorbing: list.length == 1? true : falseThis allows for dragging the items only if the list has more than 1 item
elogir commentedon Dec 18, 2024
@26sameer That's a fix that works only if your item has no interactivity, as AbsorbPointer will... Absorb the pointer.
fdwl commentedon Jan 13, 2025
Issue: ReorderableListView drag detection area mismatch when wrapped in Transform.scale
Description
When wrapping a
ReorderableListViewinside aTransform.scale(or when it's a child of scaled widgets), the drag detection area doesn't match the visual representation. This causes the drag handles to respond to touch events at the wrong locations.Current Setup
/dart InteractiveViewer( child: Transform( transform: Matrix4.identity()..scale(scale), child: ReorderableListView( children: [...], ), ) , )Expected Behavior
The drag detection area should match the visually scaled items, making the drag interaction feel natural and accurate.
Actual Behavior
The drag detection area remains at the original size and position, while the visual elements are scaled, causing a mismatch between where users touch and where the system detects the touch.
Reproduction Steps
ReorderableListViewwith multiple itemsTransform.scalewith a scale factor less than 1.0Example Code
···
dart
class MyWidget extends StatefulWidget {
@OverRide
State createState() => MyWidgetState();
}
class MyWidgetState extends State {
@OverRide
Widget build(BuildContext context) {
return Transform.scale(
scale: 0.5, // Any scale factor less than 1.0 will demonstrate the issue
child: ReorderableListView(
children: List.generate(
5,
(index) => ListTile(
key: ValueKey(index),
title: Text('Item $index'),
),
),
onReorder: (oldIndex, newIndex) {
// Reorder logic
},
),
);
}
}
···
Platform
Additional Context
ReorderableListViewwhen transform matrices are involvedCompositedTransformor custom drag handling) add complexity and may introduce other issuesPossible Solutions
ReorderableListViewto account for ancestor transformsReorderableListViewRelated Issues
Zuckjet commentedon Jul 1, 2025
I have encountered the same problem and have submitted a PR to fix it. I hope someone can help take a look at this PR.
fix: adjust scrollable size assertion with tolerance (#171426)
github-actions commentedon Aug 15, 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.fix: adjust scrollable size assertion with tolerance (flutter#171426)
fix: adjust scrollable size assertion with tolerance (flutter#171426)
fix: adjust scrollable size assertion with tolerance (flutter#171426)
fix: adjust scrollable size assertion with tolerance (flutter#171426)
fix: adjust scrollable size assertion with tolerance (#171426)