24 lines
631 B
Dart
24 lines
631 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class FadeRoute extends PageRouteBuilder {
|
|
final Widget page;
|
|
|
|
FadeRoute({required this.page})
|
|
: super(
|
|
pageBuilder: (context, animation, secondaryAnimation) => page,
|
|
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
|
const begin = 0.0;
|
|
const end = 1.0;
|
|
const curve = Curves.easeInOut;
|
|
|
|
final tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
|
|
final opacityAnimation = animation.drive(tween);
|
|
|
|
return FadeTransition(
|
|
opacity: opacityAnimation,
|
|
child: child,
|
|
);
|
|
},
|
|
);
|
|
}
|