freezer/lib/page_routes/fade.dart
2021-11-01 17:41:25 +01:00

42 lines
1.2 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:freezer/page_routes/basic_page_route.dart';
import 'package:freezer/ui/animated_blur.dart';
class FadePageRoute<T> extends BasicPageRoute<T> {
final WidgetBuilder builder;
final bool blur;
FadePageRoute({
required this.builder,
this.blur = false,
transitionDuration = const Duration(milliseconds: 300),
maintainState = true,
}) : super(
transitionDuration: transitionDuration,
maintainState: maintainState);
@override
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) =>
builder(context);
@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
final baseTransition = FadeTransition(
opacity: animation,
child: child,
);
if (blur) {
return Stack(children: [
Positioned.fill(
child: AnimatedBlur(
animation: animation,
multiplier: 10.0,
child: const SizedBox())),
baseTransition,
]);
}
return baseTransition;
}
}