flutter - 如何在 Flutter 中转换背景图像?
问题描述
我希望每当我加载我的屏幕时,背景图像都应该放大然后缩小。我怎样才能实现那个 inFlutter?
解决方案
添加动画页面所需的此 Initstate 代码
void initState() {
super.initState();
animationController = new AnimationController(
vsync: this, duration: new Duration(seconds: 3));
animation =
new CurvedAnimation(parent: animationController, curve: Curves.easeOut);
animation.addListener(() => this.setState(() {}));
animationController.forward();
setState(() {
_visible = !_visible;
});
}
并将其添加到您的图像小部件中
new Image.asset('assets/images/background.png',
width: animation.value * 250,
height: animation.value * 250,
),
推荐阅读
- amazon-web-services - AWS API 网关 URL 返回 {"message":"Forbidden"}
- php - Dotenv 必须是 Dotenv\Loader 的一个实例
- java - 如何从 MongoDB 和 Cosmos DB 的值字段中获取可嵌入文档?
- .net - PowerShell Active Directory 是否调用 System.DirectoryServices.AccountManagement
- python - Python:搜索和替换 HTML 字符串中的所有 img 标签
- java - java.security.NoSuchAlgorithmException:提供者 SunJCE 不提供 DES/ECB/NoPadding
- linq - 从开始工作日期开始几个月的工作经验 MVC
- javascript - 按属性在对象数组中查找重复项的最短方法
- gulp - Browserify 导出具有多个条目
- haskell - 如何将动态多态函数应用于动态值?