fix: remove controller dispose and add removeListener (#16)

This commit is contained in:
Andrea Valenzano 2023-04-24 18:04:41 +02:00 committed by GitHub
parent 3644453742
commit 852480fb57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -1,3 +1,8 @@
## NEXT
- **BREAKING CHANGE**:
- `CardSwiperController` is no longer disposed by `CardSwiper`, but who created it must dispose it.
## [4.1.3] ## [4.1.3]
- Fix Swiping when `isDisabled` is `true` and triggered by the `controller`. - Fix Swiping when `isDisabled` is `true` and triggered by the `controller`.

View File

@ -26,6 +26,12 @@ class _ExamplePageState extends State<Example> {
final cards = candidates.map((candidate) => ExampleCard(candidate)).toList(); final cards = candidates.map((candidate) => ExampleCard(candidate)).toList();
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(

View File

@ -201,7 +201,7 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
void dispose() { void dispose() {
super.dispose(); super.dispose();
_animationController.dispose(); _animationController.dispose();
widget.controller?.dispose(); widget.controller?.removeListener(_controllerListener);
} }
@override @override