Skip to content

Commit

Permalink
Fix regression for cancellation token
Browse files Browse the repository at this point in the history
  • Loading branch information
knopp committed Jan 28, 2019
1 parent 2154a94 commit 9f4dd3e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
## [0.1.2]

* Add delayed (android-like) reordering

## [0.1.3]

* Fix regression for CancellationToken
24 changes: 22 additions & 2 deletions lib/flutter_reorderable_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ class _ReorderableListState extends State<ReorderableList>
void initState() {
super.initState();
if (widget.cancellationToken != null) {
widget.cancellationToken._callbacks.add(this.cancel);
widget.cancellationToken._callbacks.add(this._cancel);
}
}

@override
void dispose() {
if (widget.cancellationToken != null) {
widget.cancellationToken._callbacks.remove(this.cancel);
widget.cancellationToken._callbacks.remove(this._cancel);
}
_finalAnimation?.dispose();
for (final c in _itemTranslations.values) {
Expand All @@ -178,6 +178,26 @@ class _ReorderableListState extends State<ReorderableList>
super.dispose();
}

void _cancel() {
if (_dragging != null) {
if (_finalAnimation != null) {
_finalAnimation.dispose();
_finalAnimation = null;
}

final dragging = _dragging;
_dragging = null;
_dragProxy.hide();

var current = _items[_dragging];
current?.update();

if (widget.onReorderDone != null) {
widget.onReorderDone(dragging);
}
}
}

// Returns currently dragged key
Key get dragging => _dragging;

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_reorderable_list
description: Reorderable list for flutter.
version: 0.1.2
version: 0.1.3
author: Matej Knopp <[email protected]>
homepage: https://github.com/knopp/flutter_reorderable_list

Expand Down

0 comments on commit 9f4dd3e

Please sign in to comment.