Skip to content

Commit d9c7a2c

Browse files
committed
Table
1 parent d6fb391 commit d9c7a2c

File tree

6 files changed

+134
-0
lines changed

6 files changed

+134
-0
lines changed

docs/widget/regular/table/index.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## **Table**
2+
3+
>
4+
该控件为其子控件进行table布局的Widget
5+
6+
### 构造方法
7+
``` dart
8+
Table({
9+
Key key,
10+
this.children = const <TableRow>[],
11+
this.columnWidths,
12+
this.defaultColumnWidth = const FlexColumnWidth(1.0),
13+
this.textDirection,
14+
this.border,
15+
this.defaultVerticalAlignment = TableCellVerticalAlignment.top,
16+
this.textBaseline,
17+
})
18+
```
19+
20+
### 属性介绍
21+
>
22+
该Widget适用于多行多列,若只有一行或者一列,选择Row或Column会更合适一些
23+
24+
* columnWidths:设置每一列的宽度
25+
* defaultColumnWidth:默认的每一列宽度值,默认情况下均分,通过FixedColumnWidth设置
26+
* textDirection:文字显示方向
27+
* border:表格边框
28+
* defaultVerticalAlignment:每一个cell的垂直方向的对齐方式, 包含5种:
29+
* top:放置在的顶部;
30+
* middle:垂直居中;
31+
* bottom:放置在底部;
32+
* baseline:文本baseline对齐;
33+
* fill:充满整个cell。
34+
* textBaseline:defaultVerticalAlignment为baseline的时候,会用到这个属性。
35+
* children: Table的中的内容widget

docs/widget/regular/wrap/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ Wrap({
2929
* crossAxisAlignment:交叉轴(crossAxis)方向上的对齐方式,值: WrapCrossAlignment.start/center/end
3030
* textDirection:文本方向, 值:TextDirection.ltr/rtl
3131
* verticalDirection:定义了children摆放顺序,默认是down,值: VerticalDirection.down/up
32+
* children: Table的中的内容widget

lib/widget/regular/index.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'fittedbox/index.dart' as FittedBox;
99
import 'aspectratio/index.dart' as AspectRatio;
1010
import 'constrainedbox/index.dart' as ConstrainedBox;
1111
import 'wrap/index.dart' as Wrap;
12+
import 'table/index.dart' as Table;
1213

1314
const nameSpaces = '/regular_';
1415

@@ -62,6 +63,11 @@ List widgets = [
6263
widget: Wrap.Index(),
6364
code: 59385, // pages
6465
title: Wrap.Index.title
66+
),
67+
ItemInfo(
68+
widget: Table.Index(),
69+
code: 59568, // receipt
70+
title: Table.Index.title
6571
)
6672
];
6773

lib/widget/regular/table/demo.dart

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import 'package:flutter/material.dart';
2+
3+
class Index extends StatefulWidget {
4+
@override
5+
_IndexState createState() => _IndexState();
6+
}
7+
8+
class _IndexState extends State<Index> {
9+
@override
10+
Widget build(BuildContext context) {
11+
return Scaffold(
12+
appBar: AppBar(title: Text('Table'),),
13+
body: Center(
14+
child: Container(
15+
decoration: BoxDecoration(
16+
image: DecorationImage(
17+
image: NetworkImage('http://pic1.win4000.com/wallpaper/2019-01-31/5c52bf7fdc959_270_185.jpg'),
18+
fit: BoxFit.cover
19+
)
20+
),
21+
child: Table(
22+
columnWidths: const <int, TableColumnWidth> {
23+
0: FixedColumnWidth(40.0),
24+
1: FixedColumnWidth(80.0),
25+
2: FixedColumnWidth(40.0),
26+
// 3: FixedColumnWidth(80.0)
27+
},
28+
defaultColumnWidth: FixedColumnWidth(100.0),
29+
textDirection: TextDirection.ltr,
30+
border: TableBorder.all(
31+
width: 1.0, style: BorderStyle.solid, color: Theme.of(context).primaryColor
32+
),
33+
defaultVerticalAlignment: TableCellVerticalAlignment.top,
34+
// textBaseline: TextBaseline.alphabetic,
35+
children: List.generate(4, (index) {
36+
return TableRow(
37+
children: <Widget>[
38+
Container(
39+
height: 50.0,
40+
alignment: Alignment.center,
41+
child: Text('A${index+1}', style: TextStyle(fontSize: 20.0, color: Theme.of(context).primaryColor),),
42+
),
43+
Container(
44+
height: 50.0,
45+
alignment: Alignment.center,
46+
child: Text('B${index+1}', style: TextStyle(fontSize: 20.0, color: Theme.of(context).primaryColor),),
47+
),
48+
Container(
49+
height: 50.0,
50+
alignment: Alignment.center,
51+
child: Text('C${index+1}', style: TextStyle(fontSize: 20.0, color: Theme.of(context).primaryColor),),
52+
),
53+
Container(
54+
height: 50.0,
55+
alignment: Alignment.center,
56+
child: Text('D${index+1}', style: TextStyle(fontSize: 20.0, color: Theme.of(context).primaryColor),),
57+
),
58+
]
59+
);
60+
})
61+
),
62+
),
63+
)
64+
);
65+
}
66+
}
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 = 'Table';
7+
static String originCodeUrl = '';
8+
static String mdUrl = 'docs/widget/regular/table/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+
}

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ flutter:
6666
- docs/widget/regular/aspectratio/
6767
- docs/widget/regular/constrainedbox/
6868
- docs/widget/regular/wrap/
69+
- docs/widget/regular/table/
6970
# An image asset can refer to one or more resolution-specific "variants", see
7071
# https://flutter.io/assets-and-images/#resolution-aware.
7172

0 commit comments

Comments
 (0)