初始化

This commit is contained in:
zhutao
2025-11-19 17:56:39 +08:00
commit 1b28239352
115 changed files with 5440 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
enum SlideDirection { up, down }
class SlideHide extends StatefulWidget {
final Widget child;
final bool hide; // 是否隐藏
final SlideDirection direction;
final Duration duration;
const SlideHide({
super.key,
required this.child,
this.hide = false,
this.direction = SlideDirection.up,
this.duration = const Duration(milliseconds: 200),
});
@override
State<SlideHide> createState() => _SlideHideState();
}
class _SlideHideState extends State<SlideHide> with SingleTickerProviderStateMixin {
late final AnimationController _controller;
late final Animation<Offset> _animation;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: widget.duration,
);
_animation = Tween<Offset>(
begin: Offset.zero,
end: widget.direction == SlideDirection.up ? const Offset(0, -1) : const Offset(0, 1),
).animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut));
if (widget.hide) {
_controller.value = 1;
}
}
@override
void didUpdateWidget(covariant SlideHide oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.hide != widget.hide) {
if (widget.hide) {
_controller.forward();
} else {
_controller.reverse();
}
}
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return SlideTransition(
position: _animation,
child: widget.child,
);
}
}