Skip to content

Commit e9dd717

Browse files
committed
flow
1 parent d1a4965 commit e9dd717

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed

docs/widget/regular/flow/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## **Flow**

lib/widget/regular/flow/demo.dart

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import 'package:flutter/material.dart';
2+
3+
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+
},
23+
];
24+
25+
@override
26+
Widget build(BuildContext context) {
27+
return Scaffold(
28+
appBar: AppBar(title: Text('Flow'),),
29+
body: Flow(
30+
delegate: TestFlowDelegate(margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0)),
31+
children: List.generate(6, (index) {
32+
return Container(
33+
width: 40.0,
34+
height: 40.0,
35+
color: containerValue[index]['color'],
36+
);
37+
}),
38+
),
39+
);
40+
}
41+
}
42+
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 {
54+
EdgeInsets margin = EdgeInsets.zero;
55+
56+
TestFlowDelegate({this.margin});
57+
@override
58+
void paintChildren(FlowPaintingContext context) {
59+
var x = margin.left;
60+
var y = margin.top;
61+
for (int i = 0; i < context.childCount; i++) {
62+
var w = context.getChildSize(i).width + x + margin.right;
63+
if (w < context.size.width) {
64+
context.paintChild(i,
65+
transform: new Matrix4.translationValues(
66+
x, y, 0.0));
67+
x = w + margin.left;
68+
} else {
69+
x = margin.left;
70+
y += context.getChildSize(i).height + margin.top + margin.bottom;
71+
context.paintChild(i,
72+
transform: new Matrix4.translationValues(
73+
x, y, 0.0));
74+
x += context.getChildSize(i).width + margin.left + margin.right;
75+
}
76+
}
77+
}
78+
79+
@override
80+
bool shouldRepaint(FlowDelegate oldDelegate) {
81+
return oldDelegate != this;
82+
}
83+
}

lib/widget/regular/flow/index.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
3+
import 'demo.dart' as Demo;
4+
5+
class Index extends StatefulWidget {
6+
static String title = 'Flow';
7+
static String originCodeUrl = '';
8+
static String mdUrl = 'docs/widget/regular/flow/index.md';
9+
@override
10+
_IndexState createState() => _IndexState();
11+
}
12+
13+
class _IndexState extends State<Index> {
14+
@override
15+
Widget build(BuildContext context) {
16+
return WidgetComp.Index(
17+
title: Index.title,
18+
originCodeUrl: Index.originCodeUrl,
19+
mdUrl: Index.mdUrl,
20+
demoChild: <Widget>[
21+
Demo.Index()
22+
],
23+
);
24+
}
25+
}

lib/widget/regular/index.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'aspectratio/index.dart' as AspectRatio;
1010
import 'constrainedbox/index.dart' as ConstrainedBox;
1111
import 'wrap/index.dart' as Wrap;
1212
import 'table/index.dart' as Table;
13+
import 'flow/index.dart' as Flow;
1314

1415
const nameSpaces = '/regular_';
1516

@@ -68,6 +69,11 @@ List widgets = [
6869
widget: Table.Index(),
6970
code: 59568, // receipt
7071
title: Table.Index.title
72+
),
73+
ItemInfo(
74+
widget: Flow.Index(),
75+
code: 58915, // sd_card
76+
title: Flow.Index.title
7177
)
7278
];
7379

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ flutter:
6868
- docs/widget/regular/constrainedbox/
6969
- docs/widget/regular/wrap/
7070
- docs/widget/regular/table/
71+
- docs/widget/regular/flow/
7172
# An image asset can refer to one or more resolution-specific "variants", see
7273
# https://flutter.io/assets-and-images/#resolution-aware.
7374

0 commit comments

Comments
 (0)