import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(title: '动画demo2', home: FirstPage());
}
}
//实现点击缩略图进行路由跳转,图片尺寸变大
class FirstPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('动画路由-FirstPage'),
),
body: Center(
child: Container(
alignment: Alignment.topCenter,
child: InkWell(
child: Hero(
tag: 'avatar',
child: ClipOval(
child: Image.asset(
'imgs/demo.jpg',
width: 50,
),
),
),
onTap: () {
Navigator.push(context, PageRouteBuilder(pageBuilder:
(BuildContext context, Animation animation,
Animation secondaryAnimation) {
return FadeTransition(
opacity: animation,
child: Scaffold(
appBar: AppBar(
title: Text('原图'),
),
body: SecondPage(),
),
);
}));
},
),
),
),
);
}
}
class SecondPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Hero(
tag: 'avatar',
child: Image.asset('imgs/demo.jpg'),
),
);
}
}
运行效果: