generated from dellevin/template
动画效果美化
This commit is contained in:
28
lib/utils/slide_up_page_route.dart
Normal file
28
lib/utils/slide_up_page_route.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 自定义页面过渡动画 — 向上滑入 + 淡入
|
||||
class SlideUpPageRoute extends PageRouteBuilder {
|
||||
SlideUpPageRoute({required Widget page})
|
||||
: super(
|
||||
pageBuilder: (context, animation, secondaryAnimation) => page,
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
const begin = Offset(0.0, 0.08);
|
||||
const end = Offset.zero;
|
||||
final tween = Tween(begin: begin, end: end).chain(
|
||||
CurveTween(curve: Curves.easeOutCubic),
|
||||
);
|
||||
final fadeTween = Tween<double>(begin: 0.0, end: 1.0).chain(
|
||||
CurveTween(curve: const Interval(0.0, 0.3, curve: Curves.easeOut)),
|
||||
);
|
||||
return SlideTransition(
|
||||
position: animation.drive(tween),
|
||||
child: FadeTransition(
|
||||
opacity: animation.drive(fadeTween),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
transitionDuration: const Duration(milliseconds: 350),
|
||||
reverseTransitionDuration: const Duration(milliseconds: 250),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user