50 lines
1.4 KiB
Dart
50 lines
1.4 KiB
Dart
|
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<Widget> 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,
|
||
|
onDone: (visible) {
|
||
|
if (visible) {
|
||
|
displayIndex.value = displayIndex.value + 1;
|
||
|
if (displayIndex.value == children.length) {
|
||
|
onDone?.call();
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
child: child,
|
||
|
)),
|
||
|
],
|
||
|
);
|
||
|
}
|
||
|
}
|