试试这个例子,把 push 改成 pushReplacement,改变页面转换的速度:
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Container(height: 200, color: Colors.blue),
Hero(
tag: 'YearReport',
child: Container(
height: 150,
child: Card(
child: ListTile(
title: Text("Year Report 70%"),
leading: CircleAvatar(
child: Text("YR"),
backgroundColor: Colors.white,
),
onTap: () {
print(curveList.length);
Navigator.of(context).push(PageRouteBuilder(
pageBuilder: (context, animation, anotherAnimation) {
return Scaffold(
body: Column(
children: [
Hero(
tag: 'YearReport',
child: Container(
width: MediaQuery.of(context).size.width,
child: Text("Year Report", style: TextStyle(fontSize: 60)),
),
),
Container(height: 200, color: Colors.red),
Expanded(
child: Container(color: Colors.green),
),
],
),
);
},
transitionDuration: Duration(
milliseconds:
3000), //Change your page transition speed
transitionsBuilder:
(context, animation, anotherAnimation, child) {
animation = CurvedAnimation(
curve: Curves.linear, parent: animation);
return Align(
child: SizeTransition(
sizeFactor: animation,
child: child,
axisAlignment: 0.0,
),
);
}));
},
),
),
),
),
Expanded(
child: Container(color: Colors.white),
),
],
),
);