android hero动画,Flutter Hero动画开发实用教程 - 贾鹏辉的技术博客官网|CrazyCodeBoy|Devio|专注移动技术开发(Android&IOS)、Flutter开发、...

...

class RadialExpansionDemo extends StatelessWidget {

static const double kMinRadius = 32.0;

static const double kMaxRadius = 128.0;

static const opacityCurve = const Interval(0.0, 0.75, curve: Curves.fastOutSlowIn);

static RectTween _createRectTween(Rect begin, Rect end) {

return MaterialRectCenterArcTween(begin: begin, end: end);

}

static Widget _buildPage(BuildContext context, String imageName, String description) {

return Container(

color: Theme.of(context).canvasColor,

child: Center(

child: Card(

elevation: 8.0,

child: Column(

mainAxisSize: MainAxisSize.min,

children: [

SizedBox(

width: kMaxRadius * 2.0,

height: kMaxRadius * 2.0,

child: Hero(

createRectTween: _createRectTween,

tag: imageName,

child: RadialExpansion(

maxRadius: kMaxRadius,

child: Photo(

photo: imageName,

onTap: () {

Navigator.of(context).pop();

},

),

),

),

),

Text(

description,

style: TextStyle(fontWeight: FontWeight.bold),

textScaleFactor: 3.0,

),

const SizedBox(height: 16.0),

],

),

),

),

);

}

Widget _buildHero(BuildContext context, String imageName, String description) {

return Container(

width: kMinRadius * 2.0,

height: kMinRadius * 2.0,

child: Hero(

createRectTween: _createRectTween,

tag: imageName,

child: RadialExpansion(

maxRadius: kMaxRadius,

child: Photo(

photo: imageName,

onTap: () {

Navigator.of(context).push(

PageRouteBuilder(

pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) {

return AnimatedBuilder(

animation: animation,

builder: (BuildContext context, Widget child) {

return Opacity(

opacity: opacityCurve.transform(animation.value),

child: _buildPage(context, imageName, description),

);

}

);

},

),

);

},

),

),

),

);

}

@override

Widget build(BuildContext context) {

timeDilation = 5.0; // 1.0 is normal animation speed.

return Scaffold(

appBar: AppBar(

title: const Text('Radial Transition Demo'),

),

body: Container(

padding: const EdgeInsets.all(32.0),

alignment: FractionalOffset.bottomLeft,

child: Row(

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

_buildHero(context, 'https://raw.githubusercontent.com/flutter/website/master/examples/_animation/radial_Hero_animation/images/chair-alpha.png', 'Chair'),

_buildHero(context, 'https://raw.githubusercontent.com/flutter/website/master/examples/_animation/radial_Hero_animation/images/binoculars-alpha.png', 'Binoculars'),

_buildHero(context, 'https://raw.githubusercontent.com/flutter/website/master/examples/_animation/radial_Hero_animation/images/beachball-alpha.png', 'Beach ball'),

],

),

),

);

}

}

...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值