I'm trying to implement drag and drop for the timeline view and every time I drag an appointment between rows (ie. resources) I get this error:
Unsupported operation: Cannot remove from an unmodifiable listThis is the view I'm working with. Dragging horizontally within a row (ie. changing the time but not the resource) works fine, but dragging vertically between rows always results in that same error.
The exception is caused by this code inside calendar_view.dart:
Any help would be greatly appreciated! Thanks and have a good day :)
══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
The following UnsupportedError was thrown while handling a gesture:
Unsupported operation: Cannot remove from an unmodifiable list
When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 288:49 throw_
dart-sdk/lib/internal/list.dart 134:5 remove
packages/syncfusion_flutter_calendar/src/calendar/views/calendar_view.dart 2281:22 [_handleLongPressEnd]
packages/syncfusion_flutter_calendar/src/calendar/views/calendar_view.dart 2515:7 [_handleDragEnd]
packages/syncfusion_flutter_calendar/src/calendar/views/calendar_view.dart 722:37 <fn>
packages/flutter/src/gestures/monodrag.dart 540:41 <fn>
packages/flutter/src/gestures/recognizer.dart 275:24 invokeCallback
packages/flutter/src/gestures/monodrag.dart 540:5 [_checkEnd]
Hi grady,
As per the shared information, we have checked the mentioned issue “Drag and drop through errors between resources in the timelineviews in the Flutter Calendar” and it was working fine as expected from our end and we are able to dragdrop the appointment between the resources. Please find the sample and video from the attached link.
Please check the sample and let us know if you still facing the same issue? If not, please modify the sample based on your scenario and revert us with following details,
Code snippet
Replication procedure or video
It will be helpful for us to check on it and
provide you solution at the earliest.
Regards,
Indumathi R
Attachment: resourceview_8677e978.zip
Thank you for your quick response!
I have looked at the example and I am uncertain why my version doesn't work.
When I drag a shift, onDragStart gets called, but onDragEnd does not, because I end up with the error
Unsupported operation: Cannot remove from an unmodifiable list
during _handleLongPress
Please take a look and let me know if you can see what I'm doing wrong. Thanks!
Here is my code:
Hi Grady,
Based on the shared code snippet, we are unable to run the sample. But, using our sample we have added the onDragStart(), onDragEnd() callbacks and ensured, there is no error from our end, it was working fine as expected from our end. Also, can you please ensure once the convertAppointmentToObject() method is implemented and this method must be implemented for appointment drag and drop.
Tested version:
Flutter – Channel version 3.13.0 (Stable)
Syncfusion Flutter calendar version – 22.2.11
If possible, can you please check with the above details once and share the error details clearly. It would be helpful for us to analyze and provide you a solution at the earliest. Also please find the sample from the attached link.
Regards,
Indumathi R
So the issue seems to be that the resourceIds field on appointment does not contain a List<Object> but an EqualUnmodifiableListView<Object>.
I am not sure why this happens, as I am only ever declaring List<Object>.
Any insights on this?
I figured it out. Turns out that unless you declare a list using the [] syntax, Dart makes it immutable by default.
Hi Grady,
We are glad to know that the issue resolved at your end. Please get in touch with us if you would require any further assistance.
Regards,
Indumathi R