重构example项目结构
This commit is contained in:
39
example/lib/animated_category_item.dart
Normal file
39
example/lib/animated_category_item.dart
Normal file
@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AnimatedCategoryItem extends StatelessWidget {
|
||||
AnimatedCategoryItem({
|
||||
required double startDelayFraction,
|
||||
required this.controller,
|
||||
required this.child,
|
||||
}) : topPaddingAnimation = Tween(
|
||||
begin: 0.0,
|
||||
end: 16.0,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: controller,
|
||||
curve: Interval(
|
||||
0.000 + startDelayFraction,
|
||||
0.400 + startDelayFraction,
|
||||
curve: Curves.ease,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final Widget child;
|
||||
final AnimationController controller;
|
||||
final Animation<double> topPaddingAnimation;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, child) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(top: topPaddingAnimation.value),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user