- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
就像我要通过动画Scaffold background-color
更改的标题一样。在onPageChanged PageView
上,我触发了动画。到现在为止还挺好。问题在于更多的颜色。我的意思是,我必须从API中获取颜色,并且当用户滚动卡(PageView
)时,我必须调整该卡的颜色。
有什么建议么?
这是2种颜色的当前代码(带有预览):DartPad。
提前致谢 :)
最佳答案
使用 TweenSequence<Color>
假设序列中每种颜色的权重相同,则可以使用index / colors.length
找到给定的颜色,如我在onPageChanged
回调中所示。
鉴于此,_controller.animateTo(index / colors.length)
将采用AnimationController
中指定的持续时间,以从当前颜色到新颜色的任一方向进行动画处理。
这是一个live demo
这是相关的代码(仅显示您所做的更改)。我根据个人喜好更改了持续时间和动画物理。务必使用您喜欢的东西。
class _HomepageScreenState extends State<HomepageScreen>
with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation<Color> animation;
final colors = <TweenSequenceItem<Color>>[
TweenSequenceItem(
weight: 1.0,
tween: ColorTween(begin: Colors.red, end: Colors.blue),
),
TweenSequenceItem(
weight: 1.0,
tween: ColorTween(begin: Colors.blue, end: Colors.green),
),
TweenSequenceItem(
weight: 1.0,
tween: ColorTween(begin: Colors.green, end: Colors.yellow),
),
TweenSequenceItem(
weight: 1.0,
tween: ColorTween(begin: Colors.yellow, end: Colors.red),
),
];
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(milliseconds: 600),
vsync: this,
);
animation = TweenSequence<Color>(colors).animate(_controller)..addListener(() {
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: animation.value,
body: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: PageView.builder(
physics: new PageScrollPhysics(),
itemCount: colors.length,
controller: PageController(viewportFraction: 0.8),
onPageChanged: ((int index) {
_controller.animateTo(index / colors.length);
}),
itemBuilder: (_, i) {
return Padding(
padding:
EdgeInsets.only(left: i % 2 == 0 ? 0 : 15, bottom: 20),
child: Container(),
);
},
),
),
],
),
),
);
}
}
关于flutter - 设置脚手架背景色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62477822/
我读了here您可以使用命令构建模块,因此您无需手动创建一些初始文件。但是这样的命令在 master 上不起作用(在 Odoo 开发分支上): ./oe scaffold Academy ../my-
我是 Grails 新手。我有一个 Person 域类: class Person { String firstName String lastName String gend
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我使用 yeoman 作为脚手架工具,但出现以下错误。任何人都可以帮我解决这个问题。我正在使用 Windows 8 环境。 karma-jasmine@0.1.5 node_modules\karma
我正在查看使用grails generate-all生成的 Controller 。为什么同时存在create和save操作,是否有原因?对于我来说,仅将create作为操作并将save作为服务对我来
我是个新手。我现在正在研究脚手架模板,尤其是在 Controller 上。我每次生成时都想要一个自定义的 Controller ,所以我使用了“安装模板”。我总是在 Controller 上创建Com
我有一个类库,其中包含一些模型类和一个 DbContext 类(所有这些类都是公共(public)的)。该类库由 MVC-5 应用程序引用。 是否可以使用该引用类库中的模型类来构建该 MVC-5 应用
我有一个使用 Twitter Bootstrap 构建的单页应用程序。我的应用程序有几个模态对话框,它们通常占页面宽度的 70%,并且水平居中。我的页面和模态设置是这样的: 我在模态框内放置了一行和几
我正在开发一个具有某种“协调器”界面的网络应用程序。我希望能够支持我正在使用的 Eyefinity 设置(即 3 个纵向显示器,分辨率为 3600x1920,或 3780x1920,并启用了边框校正)
在处理 codeigniter 中的脚手架时,我有哪些选择 - 人们经常使用脚手架吗?或者是否有更好的方法来快速生成用于 CRUD 应用程序的代码? 我已经安装了 Spark 塞:http://cod
我正在我工作的公司解决方案中实现存储库模式,将后端项目中的模型类与 DbContexts 项目中的数据库上下文和迁移分开。 我正在使用 Scaffold-DbContext 将我的后端项目设置为模型类
目录 1、前言 2、什么是脚手架呢? 3、谁提供了脚手架? 1、Spring 官网脚手架 2、阿里云脚手架 4、手撸一个脚手架!
我在脚手架中有一个应用栏。 return Scaffold( appBar: styling.appBar( AppBar( leading: styling.icon
我正在尝试使用 Compose 设计一个布局,其中包括: 热门应用栏 正文(内容) 底部应用栏 单击时表示菜单的底部表(模态底部表) -------TopAppBar------ ------主要内容
有谁知道如何为所有对象属性“构建”或“生成”构造函数块?我有 VS2010 和 Resharper,我希望生成类似的东西: public Customer CustomerB = new Cu
我正在尝试在 grails 中上传文件。生成的脚手架对我不起作用,给我一个 404 寻找“save.jsp” 域名 class Simple{ byte [] avatar static co
因为我已经手动调整了我的实体和 Controller 以及 View ,所以我希望 roo 不更改它们中的任何一个。尽管如此,我还是希望继续为所有新实体搭建脚手架。我怎么能那样做 最佳答案 您可以通过
我使用命令grails generate-restful-controller Domain创建了一个 Restful Controller ,如何在创建的 Controller 中设置scaffol
我有一个定义了 staticscaffold = true 的 Controller ,以及一些自定义操作。 我想确保只有登录用户和 ADMIN 类型的用户(我们域中的某些 Enum 值)才能访问它。
我有一个表,其中某些列的值相对较长,并且在我的 Grails 应用程序中为其打开了动态脚手架(我使用的是 Grails 3.3.8)。因此,在某些屏幕分辨率下,它们不适合屏幕,并且最右边的列最终会出现
我是一名优秀的程序员,十分优秀!