当前位置:网站首页>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
边栏推荐
- About Random Numbers
- 一键加速索尼相机SD卡文件的复制操作,文件操作批处理教程
- 论文解读(LG2AR)《Learning Graph Augmentations to Learn Graph Representations》
- memcached基础
- 从位图到布隆过滤器,C#实现
- Network in network (dolls)
- Solve the problem that only one line of text is displayed or not displayed in u8glib
- JSON parsing, esp32 easy access to time, temperature and weather
- Law of Large Numbers
- 自定义JSP[if,foreach,数据,select]标签
猜你喜欢
随机推荐
find_circ详细使用指南
xml学习笔记
buuctf-pwn write-ups (6)
Esp32-solo development tutorial to solve config_ FREERTOS_ UNICORE problem
玩转OLED,U8g2动画,增长数字和随机三角形等
memcached基础5
idea 热启动失效解决方案
USB协议中HID设备描述符以及键盘按键值对应编码表
In depth understanding of UDP in the transport layer and the use of UDP in sockets
Overview of Freescale MCU
Reading graph augmentations to learn graph representations (lg2ar)
How to write test cases and a brief introduction to go unit test tool testify
One click acceleration of Sony camera SD card file copy operation, file operation batch processing tutorial
解决unable to create a folder to save the sketch: mkdir sketch
Statistical Hypothesis Testing
Review the old and know the new -- constant renewal at normal temperature
memcached基础3
Moher College - SQL injection vulnerability test (error reporting and blind note)
这10款文案神器帮你速码,做自媒体还担心写不出文案吗?
buuctf-pwn write-ups (6)








![Custom jsp[if, foreach, data, select] tag](/img/a2/fc75c182d572d86f4466323e31d6c3.png)