letsar / flutter_slidable

A Flutter implementation of slidable list item with directional slide actions.
MIT License
2.73k stars 592 forks source link

This widget has been unmounted, so the State no longer has a context (and should be considered defunct). #482

Open hkaikai opened 4 months ago

hkaikai commented 4 months ago

when I wrap the Slidable component with the SlidableAutoCloseBehavior component, closing the ActionPane throws an error

flutter:3.7 flutter_slidable:3.1.0 ios simulator:15 pro max(ios 17.5)

════════ Exception caught by animation library ═════════════════════════════════
The following assertion was thrown while notifying status listeners for AnimationController:
This widget has been unmounted, so the State no longer has a context (and should be considered defunct).

Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.
When the exception was thrown, this was the stack
#0      State.context.<anonymous closure>
framework.dart:947
#1      State.context
framework.dart:953
#2      _SlidableAutoCloseBarrierNotificationSenderState._handleStatusChanged
auto_close_behavior.dart:362
#3      _SlidableNotificationSenderState.handleStatusChanged
auto_close_behavior.dart:533
#4      AnimationLocalStatusListenersMixin.notifyStatusListeners
listener_helpers.dart:240
#5      AnimationController._checkStatusChanged
animation_controller.dart:822
#6      AnimationController.value=
animation_controller.dart:370
#7      SlidableController.ratio=
controller.dart:215
#8      _SlidableGestureDetectorState.handleDragUpdate
gesture_detector.dart:90
#9      DragGestureRecognizer._checkUpdate.<anonymous closure>
monodrag.dart:483
#10     GestureRecognizer.invokeCallback
recognizer.dart:253
#11     DragGestureRecognizer._checkUpdate
monodrag.dart:483
#12     DragGestureRecognizer.handleEvent
monodrag.dart:330
#13     PointerRouter._dispatch
pointer_router.dart:98
#14     PointerRouter._dispatchEventToRoutes.<anonymous closure>
pointer_router.dart:143
#15     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#16     PointerRouter._dispatchEventToRoutes
pointer_router.dart:141
#17     PointerRouter.route
pointer_router.dart:127
#18     GestureBinding.handleEvent
binding.dart:460
#19     GestureBinding.dispatchEvent
binding.dart:440
#20     RendererBinding.dispatchEvent
binding.dart:336
#21     GestureBinding._handlePointerEventImmediately
binding.dart:395
#22     GestureBinding.handlePointerEvent
binding.dart:357
#23     GestureBinding._flushPointerEventQueue
binding.dart:314
#24     GestureBinding._handlePointerDataPacket
binding.dart:295
#25     _invoke1 (dart:ui/hooks.dart:164:13)
#26     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:361:7)
#27     _dispatchPointerDataPacket (dart:ui/hooks.dart:91:31)
The AnimationController notifying status listeners was: AnimationController#43b2a(▶ 0.038; paused)
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by animation library ═════════════════════════════════
This widget has been unmounted, so the State no longer has a context (and should be considered defunct).
════════════════════════════════════════════════════════════════════════════════
letsar commented 4 months ago

Hi, can you provide a simple example code to reproduce this issue?

shahmirzali49 commented 2 months ago

same error :/

shahmirzali49 commented 2 months ago

I added key to SlidableAutoCloseBehavior and error gone.

 child: SlidableAutoCloseBehavior(
                                  key: const ValueKey(
                                      "slidableAutoCloseBehavior"),
                                  child: ListView.separated(
                                    controller: scrollController,