Is there a way to check if Slidable.of(context) is mounted and if slidable is closed?
Hi, in the release 0.6.0 i had this method
static void openAndCloseAnimation(BuildContext context,
{required SlideActionType actionType}) {
final slidable = Slidable.of(context);
final isClosed = slidable!.renderingMode == SlidableRenderingMode.none;
if (isClosed) {
Future.delayed(Duration.zero, () {
if (slidable.mounted) {
slidable.open(actionType: actionType);
Future.delayed(animationDuration, () {
if (slidable.mounted) {
slidable.close();
}
});
}
});
}
}
This worked perfectly fine and it would open and close one entry in the list. It is like a "tutorial" to show user that some entries have some features behind it. After upgrading your package to the latest one(2.0.0) it seems that I don't have this options any more.
The updated method looks like this:
static void openAndCloseAnimation(BuildContext context,
{required ActionPaneType actionType}) {
final slidable = Slidable.of(context);
final isClosed = slidable!.actionPaneType.value == ActionPaneType.none;
if (isClosed) {
Future.delayed(Duration.zero, () {
// missing =>If(slidable.mounted)
if (actionType == ActionPaneType.start) {
slidable.openStartActionPane(
duration: animationDuration,
);
} else if (actionType == ActionPaneType.end) {
slidable.openEndActionPane(
duration: animationDuration,
);
}
Future.delayed(animationDuration, () {
// missing =>If(slidable.mounted)
slidable.close();
});
});
}
}
isClosed is not correct in my case anymore and it doesn't return what I need. How can we check if slidable is open/closed?
What happened with renderingMode ?
if(slidable.mounted) is not possible to check anymore because after package upgrade it's removed.
Without this check, I am getting this error every time I leave the page where I use this method. Error output:
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 559 pos 7: '_ticker != null': AnimationController.animateBack() called after AnimationController.dispose()
AnimationController methods should not be used after calling dispose.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2 AnimationController.animateBack (package:flutter/src/animation/animation_controller.dart:559:7)
#3 SlidableController.close (package:flutter_slidable/src/controller.dart:249:32)
#4 SlidableHelper.closeSlidable.<anonymous closure> (package:finmatics/helpers/slidable_helper.dart:15:17)
#5 new Future.delayed.<anonymous closure> (dart:async/future.dart:423:39)
#6 _rootRun (dart:async/zone.dart:1418:47)
#7 _CustomZone.run (dart:async/zone.dart:1328:19)
#8 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
#9<…>
Thanks for any help!
Slidable is good library, but I can't search any api document? Could you please share official document?
Slidable is good library, but I can't search any api document? Could you please share official document?
not sure what you are talking about. Official docs of the package are here https://pub.dev/packages/flutter_slidable
I also came across this issue, although I did not use the slidable.mounted property before.
The solution for me was to just check for context.mounted