Skip to content

Commit

Permalink
Fix delete animation
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sneha-s committed Feb 29, 2024
1 parent 1896fbb commit b1989a9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.0.1
## 1.0.2

* Fixed blink issue

47 changes: 19 additions & 28 deletions example/lib/utils/item_tile.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

class ItemTile extends StatefulWidget {
class ItemTile extends StatelessWidget {
final VoidCallback? onTap;
final int index;
final bool selected;
Expand All @@ -12,39 +12,30 @@ class ItemTile extends StatefulWidget {
this.selected = false,
});

@override
State<ItemTile> createState() => _ItemTileState();
}

class _ItemTileState extends State<ItemTile> {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(2),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: widget.onTap,
child: Column(
children: [
Container(
height: 60,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.primaries[widget.index % Colors.primaries.length],
),
child: Center(
child: Text(
'Item ${widget.index}',
style: const TextStyle(fontSize: 25),
),
child: Column(
children: [
Container(
height: 60,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.primaries[index % Colors.primaries.length],
),
child: Center(
child: Text(
'Item $index',
style: const TextStyle(fontSize: 25),
),
),
const SizedBox(
height: 5,
)
],
),
),
const SizedBox(
height: 5,
)
],
),
);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/src/builder/motion_animated_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ class MotionBuilderState extends State<MotionBuilder>
}

void _onItemRemoved(int itemIndex, Duration removeDuration) {
childrenMap.update(
itemIndex + 1, (value) => value.copyWith(visible: false));
final updatedChildrenMap = <int, MotionData>{};
if (childrenMap.containsKey(itemIndex)) {
for (final entry in childrenMap.entries) {
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: animated_reorderable_list
description: A Flutter Reorderable Animated List with simple implementation and smooth transition.
version: 1.0.1
version: 1.0.2
repository: https://github.com/canopas/animated_reorderable_list

environment:
Expand Down

0 comments on commit b1989a9

Please sign in to comment.