Skip to content

Instantly share code, notes, and snippets.

@mingsai
Last active December 7, 2019 19:13
Show Gist options
  • Save mingsai/8cc9be5a0c93ea420a02dc5083bc763a to your computer and use it in GitHub Desktop.
Save mingsai/8cc9be5a0c93ea420a02dc5083bc763a to your computer and use it in GitHub Desktop.
Scale Route Transition Sample (encapsulates widget)
import 'package:flutter/material.dart';
class ScaleRoute extends PageRouteBuilder {
final Widget widget;
ScaleRoute({this.widget})
: super(
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return widget;
},
transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
return new ScaleTransition(
scale: new Tween<double>(
begin: 0.0,
end: 1.0,
).animate(
CurvedAnimation(
parent: animation,
curve: Interval(
0.00,
0.50,
curve: Curves.linear,
),
),
),
child: ScaleTransition(
scale: Tween<double>(
begin: 1.5,
end: 1.0,
).animate(
CurvedAnimation(
parent: animation,
curve: Interval(
0.50,
1.00,
curve: Curves.linear,
),
),
),
child: child,
),
);
}
);
//Later you can use this effect by calling
import 'package:myapp/scale_route.dart'
Navigator.push(
context,
ScaleRoute(widget: DetailScreen()),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment