import 'package:dartx/dartx.dart'; import 'package:dreampad/app/shared/shared.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; class AnimatedColumnWidget extends HookWidget { const AnimatedColumnWidget({ super.key, required this.children, this.mainAxisAlignment = MainAxisAlignment.start, this.mainAxisSize = MainAxisSize.max, this.onDone, }); final List children; final VoidCallback? onDone; final MainAxisAlignment mainAxisAlignment; final MainAxisSize mainAxisSize; @override Widget build(BuildContext context) { final displayIndex = useState(0); return Column( mainAxisAlignment: mainAxisAlignment, mainAxisSize: mainAxisSize, children: [ ...children.mapIndexed((index, child) => AnimatedVisibilityWidget( duration: const Duration(milliseconds: 800), animationWidgetBuilder: AnimatedVisibilityWidget.fadeAnimationWidgetBuilder, isVisible: index <= displayIndex.value, isInitAnimated: index == 0, onDone: (visible) async { if (visible) { if (displayIndex.value == children.length - 1) { onDone?.call(); } else { await Future.delayed(const Duration(milliseconds: 500)); displayIndex.value = displayIndex.value + 1; } } }, child: child, )), ], ); } }