当前位置:网站首页>Flutter series: flow in flutter
Flutter series: flow in flutter
2022-06-27 01:00:00 【InfoQ】
brief introduction
Flow and FlowDelegate
class Flow extends MultiChildRenderObjectWidget
Flow({
Key? key,
required this.delegate,
List<Widget> children = const <Widget>[],
this.clipBehavior = Clip.hardEdge,
}) : assert(delegate != null),
assert(clipBehavior != null),
super(key: key, children: RepaintBoundary.wrapAll(children));
Size getSize(BoxConstraints constraints) => constraints.biggest;
BoxConstraints getConstraintsForChild(int i, BoxConstraints constraints) => constraints;
void paintChildren(FlowPaintingContext context);
bool shouldRelayout(covariant FlowDelegate oldDelegate) => false;
bool shouldRepaint(covariant FlowDelegate oldDelegate);
Flow Application
final List<IconData> buttonItems = <IconData>[
Icons.home,
Icons.ac_unit,
Icons.adb,
Icons.airplanemode_active,
Icons.account_box_rounded,
];
Widget flowButtonItem(IconData icon) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: IconButton(
icon: Icon(icon,
size: 50,
color: Colors.blue
),
onPressed: () {
buttonAnimation.status == AnimationStatus.completed
? buttonAnimation.reverse()
: buttonAnimation.forward();
},
)
);
}
AnimationController buttonAnimation = AnimationController(
duration: const Duration(milliseconds: 250),
vsync: this,
);
Widget build(BuildContext context) {
return Flow(
delegate: FlowButtonDelegate(buttonAnimation: buttonAnimation),
children:
buttonItems.map<Widget>((IconData icon) => flowButtonItem(icon)).toList(),
);
}
class FlowButtonDelegate extends FlowDelegate {
FlowButtonDelegate({required this.buttonAnimation})
: super(repaint: buttonAnimation);
final Animation<double> buttonAnimation;
@override
bool shouldRepaint(FlowButtonDelegate oldDelegate) {
return buttonAnimation != oldDelegate.buttonAnimation;
}
@override
void paintChildren(FlowPaintingContext context) {
double dy = 0.0;
for (int i = 0; i < context.childCount; ++i) {
dy = context.getChildSize(i)!.height * i;
context.paintChild(
i,
transform: Matrix4.translationValues(
0,
dy * buttonAnimation.value,
0,
),
);
}
}


summary
边栏推荐
- Flink 实战问题(七):No Watermark(Watermarks are only available EventTime is used)
- Central Limit Theorem
- find_circ详细使用指南
- Statistical Hypothesis Testing
- 小白看MySQL--windows环境安装MySQL
- 3-wire SPI screen driving mode
- 30《MySQL 教程》MySQL 存储引擎概述
- Simple and fast digital network (network dolls in the network)
- How to write test cases and a brief introduction to go unit test tool testify
- Keepalived 实现 Redis AutoFailover (RedisHA)17
猜你喜欢

Flink practical problems (VII): no watermark (watermarks are only available eventtime is used)

05 | standard design (Part 2): how to standardize the different styles of commit information, which are difficult to read?
![The [MySQL] time field is set to the current time by default](/img/40/5f1d3448259ab703c4b5dc29713a99.png)
The [MySQL] time field is set to the current time by default

buuctf-pwn write-ups (6)

自定义MVC(导成jar包)+与三层架构的区别+反射+面试题

Gaussian and Summary Stats

C#程序结构预览最基础入门

Is there anyone who doesn't know the three cores of concurrent programming?

CPU的异常处理

自定义类加载器对类加密解密
随机推荐
一键加速索尼相机SD卡文件的复制操作,文件操作批处理教程
memcached基础3
30《MySQL 教程》MySQL 存储引擎概述
Statistical Hypothesis Testing
超越锂电池——未来电池的概念
高清滑环生产过程当中的质量如何把控
Pet hospital management system based on SSMP
【Vscode】预览md文件
Unable to create a folder to save the sketch: MKDIR sketch
史上最难618,TCL夺得电视行业京东和天猫份额双第一
xml学习笔记
其他服务注册与发现
memcached基础6
Gaussian and Summary Stats
Solve the problem that stc8g1k08 program cannot run and port configuration
Keepalived 实现 Redis AutoFailover (RedisHA)14
Is there anyone who doesn't know the three cores of concurrent programming?
C#程序结构预览最基础入门
CPU exception handling
[vscade] preview MD file