30 lines
785 B
Dart
30 lines
785 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class SmoothPageTransitionBuilder extends PageTransitionsBuilder {
|
|
const SmoothPageTransitionBuilder();
|
|
|
|
@override
|
|
Widget buildTransitions<T>(
|
|
PageRoute<T> route,
|
|
BuildContext context,
|
|
Animation<double> animation,
|
|
Animation<double> secondaryAnimation,
|
|
Widget child,
|
|
) {
|
|
const begin = Offset(0.0, 0.04);
|
|
const end = Offset.zero;
|
|
const curve = Curves.easeInOutCubic;
|
|
final tween = Tween(begin: begin, end: end).chain(
|
|
CurveTween(curve: curve),
|
|
);
|
|
final fadeTween = Tween<double>(begin: 0.0, end: 1.0);
|
|
return SlideTransition(
|
|
position: animation.drive(tween),
|
|
child: FadeTransition(
|
|
opacity: animation.drive(fadeTween),
|
|
child: child,
|
|
),
|
|
);
|
|
}
|
|
}
|