flutter transition package
this transition package gives you beautiful page transitions.
usage for this transition package
it is really easy to use!
you should ensure that you add the page_transition
as a dependency in your flutter project.
dependencies:
page_transition: "^1.1.5"
than you can use it with below examples.
navigator.push(context, pagetransition(type: pagetransitiontype.fade, child: detailscreen()));
navigator.push(context, pagetransition(type: pagetransitiontype.lefttoright, child: detailscreen()));
navigator.push(context, pagetransition(type: pagetransitiontype.righttoleft, child: detailscreen()));
navigator.push(context, pagetransition(type: pagetransitiontype.uptodown, child: detailscreen()));
navigator.push(context, pagetransition(type: pagetransitiontype.downtoup, child: detailscreen()));
navigator.push(context, pagetransition(type: pagetransitiontype.scale, alignment: alignment.bottomcenter, child: detailscreen()));
navigator.push(context, pagetransition(type: pagetransitiontype.size, alignment: alignment.bottomcenter, child: detailscreen()));
navigator.push(context, pagetransition(type: pagetransitiontype.rotate, duration: duration(second: 1), child: detailscreen()));
navigator.push(context, pagetransition(type: pagetransitiontype.righttoleftwithfade, child: detailscreen()));
navigator.push(context, pagetransition(type: pagetransitiontype.lefttorightwithfade, child: detailscreen()));
usage for predefined routes
first, define the ongenerateroute
property in the materialapp
widget like below and in switch cases you can transition to your new routes:
ongenerateroute: (settings) {
switch (settings.name) {
case '/second':
return pagetransition(child: secondpage(), type: pagetransitiontype.scale);
break;
default:
return null;
}
},
after that you can use your new route like this:
navigator.pushnamed(context, '/second');
usage predefined routes with routesettings
first, define the ongenerateroute
property in the materialapp
widget like below and in switch cases you can transition to your new routes:
ongenerateroute: (settings) {
switch (settings.name) {
case '/second':
return pagetransition(
child: secondpage(),
type: pagetransitiontype.scale,
settings: settings,
);
break;
default:
return null;
}
},
after that you can use your new route like this:
navigator.pushnamed(context, '/second', arguments: "arguments data");
for more detail you can look example project.
types of transitions
- fade
- righttoleft
- lefttoright
- uptodown
- downtoup
- scale (with alignment)
- rotate (with alignment)
- size (with alignment)
- righttoleftwithfade,
- lefttorightwithfade,
curves
you can use any type of curvedanimation curves.
alignments
you can use size, scale and rotate transform alignment
contributing
pull requests are welcome. for major changes, please open an issue first to discuss what you would like to change.
please make sure to update tests as appropriate.
Comments are closed.