diff --git a/lib/src/builder/motion_animated_builder.dart b/lib/src/builder/motion_animated_builder.dart index e633182..14d1be4 100644 --- a/lib/src/builder/motion_animated_builder.dart +++ b/lib/src/builder/motion_animated_builder.dart @@ -472,6 +472,8 @@ class MotionBuilderState extends State final motionData = MotionData( endOffset: Offset.zero, startOffset: Offset.zero, visible: false); + final lastKey= childrenMap.keys.last; + childrenMap.update(lastKey, (value) => value.copyWith(visible: false)); final updatedChildrenMap = {}; if (childrenMap.containsKey(itemIndex)) { @@ -626,7 +628,7 @@ class MotionBuilderState extends State updateMotionData: (MotionData motionData) { final itemOffset = _itemOffsetAt(index); childrenMap[index] = - motionData.copyWith(startOffset: itemOffset, endOffset: itemOffset); + motionData.copyWith(startOffset: itemOffset, endOffset: itemOffset, visible: true); }, capturedThemes: InheritedTheme.capture(from: context, to: overlay.context), diff --git a/lib/src/component/motion_animated_content.dart b/lib/src/component/motion_animated_content.dart index ee03e6f..a223be3 100644 --- a/lib/src/component/motion_animated_content.dart +++ b/lib/src/component/motion_animated_content.dart @@ -76,7 +76,8 @@ class MotionAnimatedContentState extends State listState.registerItem(this); } if (oldWidget.index != widget.index) { - visible = false; + visible= widget.motionData.visible; + print("$index------------ $visible"); } WidgetsBinding.instance.addPostFrameCallback((timeStamp) { if (mounted) {