Skip to content

Commit f5251a8

Browse files
committed
feat: ListBody
1 parent d96ad3b commit f5251a8

File tree

6 files changed

+101
-1
lines changed

6 files changed

+101
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## **ListBody**
2+
3+
>
4+
该控件沿着给定的轴顺序排列子节点
5+
* ListBody是一个不常直接使用的控件,一般会配合ListView或者Column等控件使用
6+
* 在主轴上,子节点按照顺序进行布局,在交叉轴上,子节点尺寸会被拉伸,以适应交叉轴的区域
7+
* 在主轴上,给予子节点的空间必须是不受限制的(unlimited),使得子节点可以全部被容纳,ListBody不会去裁剪或者缩放其子节点
8+
9+
### 构造方法
10+
``` dart
11+
ListBody({
12+
Key key,
13+
this.mainAxis = Axis.vertical,
14+
this.reverse = false,
15+
List<Widget> children = const <Widget>[],
16+
})
17+
```
18+
19+
### 属性介绍
20+
* mainAxis:排列的主轴方向,Axis.vertical/horizontal
21+
* reverse:是否反向
22+
* children:ListBody中的内容Widget

lib/widget/regular/index.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'table/index.dart' as Table;
1313
import 'flow/index.dart' as Flow;
1414
import 'stack/index.dart' as Stack;
1515
import 'listview/index.dart' as ListView;
16+
import 'listbody/index.dart' as ListBody;
1617

1718
const nameSpaces = '/regular_';
1819

@@ -86,6 +87,11 @@ List widgets = [
8687
widget: ListView.Index(),
8788
code: 60236, // spa
8889
title: ListView.Index.title
90+
),
91+
ItemInfo(
92+
widget: ListBody.Index(),
93+
code: 57440, // art_track
94+
title: ListBody.Index.title
8995
)
9096
];
9197

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_screenutil/flutter_screenutil.dart';
3+
4+
class Index extends StatelessWidget {
5+
List listview = [
6+
'http://pic1.win4000.com/wallpaper/2019-02-15/5c664c3e1d90c.jpg',
7+
'http://pic1.win4000.com/wallpaper/2019-02-15/5c664c40f3bc2.jpg',
8+
'http://pic1.win4000.com/wallpaper/2019-02-15/5c664c4406144.jpg',
9+
'http://pic1.win4000.com/wallpaper/2019-02-15/5c664c46823f8.jpg',
10+
'http://pic1.win4000.com/wallpaper/2019-02-15/5c664c48c73d0.jpg',
11+
'http://pic1.win4000.com/wallpaper/2019-02-15/5c664c4b4dc2f.jpg',
12+
'http://pic1.win4000.com/wallpaper/2019-02-15/5c664c51a2a45.jpg',
13+
'http://pic1.win4000.com/wallpaper/2019-02-14/5c65107a0ee05.jpg',
14+
'http://pic1.win4000.com/wallpaper/2019-02-14/5c65108043791.jpg',
15+
'http://pic1.win4000.com/wallpaper/2019-02-14/5c651084373de.jpg'
16+
];
17+
18+
@override
19+
Widget build(BuildContext context) {
20+
return Scaffold(
21+
appBar: AppBar(title: Text('ListBody'),),
22+
body: ListView(
23+
scrollDirection: Axis.vertical,
24+
children: <Widget>[
25+
ListBody(
26+
mainAxis: Axis.vertical,
27+
reverse: false,
28+
children: List.generate(10, (index) {
29+
return Container(
30+
width: ScreenUtil().setWidth(420),
31+
height: ScreenUtil().setHeight(220),
32+
decoration: BoxDecoration(
33+
image: DecorationImage(
34+
image: NetworkImage(listview[index]),
35+
fit: BoxFit.cover
36+
)
37+
),
38+
);
39+
}),
40+
),
41+
],
42+
)
43+
);
44+
}
45+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 = 'ListBody';
7+
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/ListBody-class.html';
8+
static String mdUrl = 'docs/widget/regular/listbody/index.md';
9+
10+
@override
11+
_IndexState createState() => _IndexState();
12+
}
13+
14+
class _IndexState extends State<Index> {
15+
@override
16+
Widget build(BuildContext context) {
17+
return WidgetComp.Index(
18+
title: Index.title,
19+
originCodeUrl: Index.originCodeUrl,
20+
mdUrl: Index.mdUrl,
21+
demoChild: <Widget>[
22+
Demo.Index()
23+
],
24+
);
25+
}
26+
}

lib/widget/regular/listview/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'demo_custom.dart' as DemoCustom;
77

88
class Index extends StatefulWidget {
99
static String title = 'ListView';
10-
static String originCodeUrl = '';
10+
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/ListView-class.html';
1111
static String mdUrl = 'docs/widget/regular/listview/index.md';
1212
@override
1313
_IndexState createState() => _IndexState();

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ flutter:
7676
- docs/widget/regular/flow/
7777
- docs/widget/regular/stack/
7878
- docs/widget/regular/listview/
79+
- docs/widget/regular/listbody/
7980
- docs/widget/navigator/appbar/
8081
- docs/widget/navigator/scaffold/
8182
# An image asset can refer to one or more resolution-specific "variants", see

0 commit comments

Comments
 (0)