KenBurns
Ken Burns 效果是一种用于静止图像视频制作的平移和缩放效果。
首先将依赖项添加到您的项目中
dependencies:
kenburns_nullsafety:
然后导入
import 'package:kenburns_nullsafety/kenburns_nullsafety.dart';
使用KenBurns组件包裹您的图片
Container(
height: 300,
child: KenBurns(
child: Image.network("https://lemag.nikonclub.fr/wp-content/uploads/2017/07/08.jpg", fit: BoxFit.cover,),
),
),
配置
您可以配置KenBurns组件
KenBurns(
minAnimationDuration : Duration(milliseconds: 3000),
maxAnimationDuration : Duration(milliseconds: 10000),
maxScale : 8,
child: ...
});
多张图片
您可以使用交叉淡入动画在KenBurns中显示多个子组件
Container(
height: 300,
child: KenBurns.multiple(
childLoop: 3,
children: [
Image.network(
"https://www.photo-paysage.com/?file=pic_download_link/picture&pid=3100",
fit: BoxFit.cover,
),
Image.network(
"https://cdn.getyourguide.com/img/location_img-59-1969619245-148.jpg",
fit: BoxFit.cover,
),
Image.network(
"https://www.theglobeandmail.com/resizer/vq3O7LI3hvsjTP2N0m9NwU4W3Eg=/1500x0/filters:quality(80)/arc-anglerfish-tgam-prod-tgam.s3.amazonaws.com/public/4ETF3GZR3NA3RDDW23XDRBKKCI",
fit: BoxFit.cover,
),
],
),
),
