Skip to content

Commit afcebfc

Browse files
committed
flow
1 parent e9dd717 commit afcebfc

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

docs/widget/regular/flow/index.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
## **Flow**
1+
## **Flow**
2+
3+
>
4+
实现优化流式布局以使用流布局的控件
5+
* 实现较为复杂,一般可通过Wrap来替换实现
6+
7+
## 构造方法
8+
``` dart
9+
Flow({
10+
Key key,
11+
@required this.delegate,
12+
List<Widget> children = const <Widget>[],
13+
})
14+
```
15+
16+
### 属性介绍
17+
* delegeate: 影响布局的FlowDelegate,包含方法如下:
18+
* paintChildren: child的绘制控制代码,可以调整尺寸位置
19+
* shouldPepaint:是否需要重绘
20+
* shouldRelayout:是否需要重新布局
21+
* getConstraintsForChild:设置每个child的约束条件,会覆盖已有
22+
* getSize: 设置Flow的尺寸
23+
* children: Flow中的内容widget

lib/widget/regular/flow/demo.dart

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,37 @@
11
import 'package:flutter/material.dart';
22

33
class Index extends StatelessWidget {
4-
List<Map<String, dynamic>> containerValue = [
5-
{
6-
'color': Colors.yellow
7-
},
8-
{
9-
'color': Colors.green
10-
},
11-
{
12-
'color': Colors.red
13-
},
14-
{
15-
'color': Colors.black
16-
},
17-
{
18-
'color': Colors.blue
19-
},
20-
{
21-
'color': Colors.lightGreenAccent
22-
},
4+
List<dynamic> containerValue = [
5+
Colors.deepOrangeAccent,
6+
Colors.cyanAccent,
7+
Colors.limeAccent,
8+
Colors.deepPurpleAccent,
9+
Colors.indigo,
10+
Colors.lightGreenAccent
2311
];
2412

2513
@override
2614
Widget build(BuildContext context) {
2715
return Scaffold(
2816
appBar: AppBar(title: Text('Flow'),),
2917
body: Flow(
30-
delegate: TestFlowDelegate(margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0)),
18+
delegate: FlowDelegateFunc(margin: EdgeInsets.fromLTRB(12.0, 12.0, 12.0, 12.0)),
3119
children: List.generate(6, (index) {
3220
return Container(
33-
width: 40.0,
21+
width: 46.0,
3422
height: 40.0,
35-
color: containerValue[index]['color'],
23+
color: containerValue[index],
3624
);
3725
}),
3826
),
3927
);
4028
}
4129
}
4230

43-
class FlowDelegates extends FlowDelegate {
44-
@override
45-
void paintChildren(FlowPaintingContext context) {}
46-
47-
@override
48-
bool shouldRepaint(FlowDelegate oldDelegeate) {
49-
return oldDelegeate != this;
50-
}
51-
}
52-
53-
class TestFlowDelegate extends FlowDelegate {
31+
class FlowDelegateFunc extends FlowDelegate {
5432
EdgeInsets margin = EdgeInsets.zero;
5533

56-
TestFlowDelegate({this.margin});
34+
FlowDelegateFunc({this.margin});
5735
@override
5836
void paintChildren(FlowPaintingContext context) {
5937
var x = margin.left;

lib/widget/regular/flow/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'demo.dart' as Demo;
44

55
class Index extends StatefulWidget {
66
static String title = 'Flow';
7-
static String originCodeUrl = '';
7+
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/Flow-class.html';
88
static String mdUrl = 'docs/widget/regular/flow/index.md';
99
@override
1010
_IndexState createState() => _IndexState();

0 commit comments

Comments
 (0)