146 lines
3.4 KiB
Dart
146 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
//Slide Transition
|
|
class SlideLeftRoute extends PageRouteBuilder {
|
|
final Widget page;
|
|
SlideLeftRoute({this.page})
|
|
: super(
|
|
pageBuilder: (
|
|
context,
|
|
animation,
|
|
secondaryAnimation,
|
|
) =>
|
|
page,
|
|
transitionsBuilder: (
|
|
context,
|
|
animation,
|
|
secondaryAnimation,
|
|
child,
|
|
) =>
|
|
SlideTransition(
|
|
position: Tween<Offset>(
|
|
begin: const Offset(1, 0),
|
|
end: Offset.zero,
|
|
).animate(animation),
|
|
child: child,
|
|
),
|
|
);
|
|
}
|
|
|
|
class SlideLeftHideRoute extends PageRouteBuilder {
|
|
final Widget page;
|
|
// final Widget transitionPage;
|
|
SlideLeftHideRoute({this.page})
|
|
: super(
|
|
pageBuilder: (
|
|
context,
|
|
animation,
|
|
secondaryAnimation,
|
|
) =>
|
|
page,
|
|
// transitionDuration: Duration(milliseconds: 300),
|
|
transitionsBuilder: (
|
|
context,
|
|
animation,
|
|
secondaryAnimation,
|
|
child,
|
|
) {
|
|
return SlideTransition(
|
|
position: Tween<Offset>(
|
|
begin: const Offset(1, 0),
|
|
end: Offset.zero,
|
|
).animate(animation),
|
|
child: child);
|
|
},
|
|
);
|
|
}
|
|
|
|
class SlideUptRoute extends PageRouteBuilder {
|
|
final Widget page;
|
|
SlideUptRoute({this.page})
|
|
: super(
|
|
pageBuilder: (
|
|
context,
|
|
animation,
|
|
secondaryAnimation,
|
|
) =>
|
|
page,
|
|
transitionsBuilder: (
|
|
context,
|
|
animation,
|
|
secondaryAnimation,
|
|
child,
|
|
) =>
|
|
SlideTransition(
|
|
position: Tween<Offset>(
|
|
begin: const Offset(0, 1),
|
|
end: Offset.zero,
|
|
).animate(animation),
|
|
child: child,
|
|
),
|
|
);
|
|
}
|
|
|
|
//Scale Pageroute
|
|
class ScaleRoute extends PageRouteBuilder {
|
|
final Widget page;
|
|
ScaleRoute({this.page})
|
|
: super(
|
|
pageBuilder: (
|
|
context,
|
|
animation,
|
|
secondaryAnimation,
|
|
) =>
|
|
page,
|
|
transitionsBuilder: (
|
|
context,
|
|
animation,
|
|
secondaryAnimation,
|
|
child,
|
|
) =>
|
|
ScaleTransition(
|
|
scale: Tween<double>(
|
|
begin: 0.0,
|
|
end: 1.0,
|
|
).animate(
|
|
CurvedAnimation(
|
|
parent: animation,
|
|
curve: Curves.fastOutSlowIn,
|
|
),
|
|
),
|
|
child: child,
|
|
),
|
|
);
|
|
}
|
|
|
|
class FadeRoute extends PageRouteBuilder {
|
|
final Widget page;
|
|
FadeRoute({this.page})
|
|
: super(
|
|
pageBuilder: (
|
|
context,
|
|
animation,
|
|
secondaryAnimation,
|
|
) =>
|
|
page,
|
|
transitionsBuilder: (
|
|
context,
|
|
animation,
|
|
secondaryAnimation,
|
|
child,
|
|
) =>
|
|
FadeTransition(
|
|
opacity: Tween<double>(
|
|
begin: 0.0,
|
|
end: 1.0,
|
|
).animate(
|
|
CurvedAnimation(
|
|
parent: animation,
|
|
curve: Curves.easeInCubic,
|
|
),
|
|
),
|
|
child: child,
|
|
),
|
|
);
|
|
}
|