-
Notifications
You must be signed in to change notification settings - Fork 29k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolec: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13frameworkflutter/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 onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework 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
ReorderableList
or ReorderableListView.builder
widget throws when reverse:true
.
Steps to Reproduce:
- Run the sample code.
- Click/Tap on
Item 5
. This results into a crash on the console. - Drag
Item 5
triggering a reorder and place it back at its original position. This also results into a crash.
This only happens when reverse
is set to true on the widget. Note that onReorder
or onReorderEnd
never gets called in this case even if specified. (I don't know if onReorder
should be called since nothing changed but onReorderEnd
should be called which is the case for other items except the last one (first one since the list is reversed).
Expected results
No crash.
Actual results
======== Exception caught by gesture library =======================================================
The following _TypeError was thrown while routing a pointer event:
Null check operator used on a null value
When the exception was thrown, this was the stack:
#0 SliverReorderableListState._itemOffsetAt (package:flutter/src/widgets/reorderable_list.dart:911:51)
#1 SliverReorderableListState._dragEnd.<anonymous closure> (package:flutter/src/widgets/reorderable_list.dart:760:30)
#2 State.setState (package:flutter/src/widgets/framework.dart:1139:30)
#3 SliverReorderableListState._dragEnd (package:flutter/src/widgets/reorderable_list.dart:758:5)
#4 _DragInfo.end (package:flutter/src/widgets/reorderable_list.dart:1281:12)
#5 MultiDragPointerState._up (package:flutter/src/gestures/multidrag.dart:156:14)
#6 MultiDragGestureRecognizer._handleEvent (package:flutter/src/gestures/multidrag.dart:258:13)
#7 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
#8 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#9 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#10 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#11 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
#12 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:465:19)
#13 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:445:22)
#14 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:331:11)
#15 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:400:7)
#16 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:363:5)
#17 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:320:7)
#18 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:293:9)
#19 _invoke1 (dart:ui/hooks.dart:158:13)
#20 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:382:7)
#21 _dispatchPointerDataPacket (dart:ui/hooks.dart:91:31)
====================================================================================================
Code sample
Code sample
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(
title: 'MyApp Demo',
debugShowCheckedModeBanner: false,
home: MyHome(),
);
}
}
class MyHome extends StatefulWidget {
const MyHome({super.key});
@override
State<MyHome> createState() => _MyHomeState();
}
class _MyHomeState extends State<MyHome> {
final List<String> items = [
'Item 1',
'Item 2',
'Item 3',
'Item 4',
'Item 5',
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: ReorderableList(
onReorder: (int oldIndex, int newIndex) {
setState(
() {
// Taken from Flutter SDK code documentation.
if (newIndex > oldIndex) {
newIndex -= 1;
}
final String item = items.removeAt(oldIndex);
items.insert(newIndex, item);
},
);
},
itemCount: items.length,
reverse: true,
itemBuilder: (BuildContext context, int index) {
return ReorderableDragStartListener(
key: Key('$index'),
index: index,
child: Material(
child: ListTile(
title: Text(items[index]),
),
),
);
},
),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
Screen.Recording.2023-08-07.at.11.48.20.PM.mp4
Logs
Logs
Performing hot reload...
Syncing files to device macOS...
Reloaded 1 of 1013 libraries in 138ms (compile: 16 ms, reload: 53 ms, reassemble: 57 ms).
======== Exception caught by gesture library =======================================================
The following _TypeError was thrown while routing a pointer event:
Null check operator used on a null value
When the exception was thrown, this was the stack:
#0 SliverReorderableListState._itemOffsetAt (package:flutter/src/widgets/reorderable_list.dart:911:51)
#1 SliverReorderableListState._dragEnd.<anonymous closure> (package:flutter/src/widgets/reorderable_list.dart:760:30)
#2 State.setState (package:flutter/src/widgets/framework.dart:1139:30)
#3 SliverReorderableListState._dragEnd (package:flutter/src/widgets/reorderable_list.dart:758:5)
#4 _DragInfo.end (package:flutter/src/widgets/reorderable_list.dart:1281:12)
#5 MultiDragPointerState._up (package:flutter/src/gestures/multidrag.dart:156:14)
#6 MultiDragGestureRecognizer._handleEvent (package:flutter/src/gestures/multidrag.dart:258:13)
#7 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
#8 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#9 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#10 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#11 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
#12 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:465:19)
#13 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:445:22)
#14 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:331:11)
#15 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:400:7)
#16 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:363:5)
#17 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:320:7)
#18 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:293:9)
#19 _invoke1 (dart:ui/hooks.dart:158:13)
#20 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:382:7)
#21 _dispatchPointerDataPacket (dart:ui/hooks.dart:91:31)
====================================================================================================
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.5 22G74 darwin-arm64, locale en-IN)
• Flutter version 3.10.6 on channel stable at /Users/birjuvachhani/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f468f3366c (4 weeks ago), 2023-07-12 15:19:05 -0700
• Engine revision cdbeda788a
• Dart version 3.0.6
• DevTools version 2.23.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/birjuvachhani/Library/Android/sdk
• Platform android-33, build-tools 33.0.2
• Java binary at: /Users/birjuvachhani/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10406996/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• Android Studio at /Users/birjuvachhani/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10406996/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 17.0.6+0-17.0.6b829.9-10027231)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2)
• IntelliJ at /Users/birjuvachhani/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
• Flutter plugin version 75.1.4
• Dart plugin version 232.8660.129
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2)
• IntelliJ at /Users/birjuvachhani/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/232.8660.185/IntelliJ IDEA.app
• 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.78.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.64.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.5 22G74 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 115.0.5790.170
[✓] Network resources
• All expected network resources are available.
• No issues found!
SaadArdati, bernaferrari and rayliverified
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolec: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13frameworkflutter/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 onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team