32 lines
1.1 KiB
Dart
32 lines
1.1 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
import 'package:freezer/page_routes/basic_page_route.dart';
|
|
|
|
class ScaleFadePageRoute<T> extends BasicPageRoute<T> {
|
|
final WidgetBuilder builder;
|
|
final Curve animationCurve;
|
|
final tween = Tween<double>(begin: 0.975, end: 1.0);
|
|
|
|
ScaleFadePageRoute({
|
|
required this.builder,
|
|
this.animationCurve = Curves.linearToEaseOut,
|
|
Duration transitionDuration = const Duration(milliseconds: 300),
|
|
bool maintainState = true,
|
|
RouteSettings? settings,
|
|
}) : super(
|
|
transitionDuration: transitionDuration,
|
|
maintainState: maintainState,
|
|
settings: settings);
|
|
|
|
Widget buildPage(BuildContext context, Animation<double> animation,
|
|
Animation<double> secondaryAnimation) =>
|
|
builder(context);
|
|
|
|
@override
|
|
Widget buildTransitions(BuildContext context, Animation<double> _,
|
|
Animation<double> secondaryAnimation, Widget child) {
|
|
final animation =
|
|
tween.animate(CurvedAnimation(parent: _, curve: animationCurve));
|
|
return ScaleTransition(scale: animation, child: child);
|
|
}
|
|
}
|