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