dreampad/lib/app/shared/widgets/show_up.dart
2023-11-30 17:12:13 +08:00

30 lines
687 B
Dart

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class ShowUp extends HookWidget {
const ShowUp({
super.key,
required this.child,
this.duration,
});
final Widget child;
final Duration? duration;
@override
Widget build(BuildContext context) {
final controller =
useAnimationController(duration: const Duration(milliseconds: 300));
useMemoized(() async {
if (duration != null) {
await Future.delayed(duration!);
}
controller.forward();
});
return FadeTransition(
opacity: CurvedAnimation(curve: Curves.easeIn, parent: controller),
child: child,
);
}
}