Skip to content

Commit 614bc57

Browse files
committed
feat: SwitchListTile
1 parent 468c9d2 commit 614bc57

File tree

5 files changed

+98
-6
lines changed

5 files changed

+98
-6
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## **SwitchListTile**
2+
3+
>
4+
Switch是切换按钮控件,通常用于设置的选项里
5+
6+
### 构造方法
7+
``` dart
8+
Switch({
9+
Key key,
10+
@required this.value,
11+
@required this.onChanged,
12+
this.activeColor,
13+
this.activeTrackColor,
14+
this.inactiveThumbColor,
15+
this.inactiveTrackColor,
16+
this.activeThumbImage,
17+
this.inactiveThumbImage,
18+
this.materialTapTargetSize,
19+
this.dragStartBehavior = DragStartBehavior.start,
20+
})
21+
```
22+
23+
### 属性介绍
24+
* value: true:开 false:关
25+
* onChanged: 变化时回调
26+
* activeColor: 打开状态下颜色
27+
* activeTrackColor: 打开状态下track颜色
28+
* inactiveThumbColor: 关闭状态thumb颜色
29+
* inactiveTrackColor: 关闭状态track颜色
30+
* activeThumbImage: 打开状态下thumb图片
31+
* inactiveThumbImage: 关闭状态thumb图片
32+
* materialTapTargetSize: 配置点击目标的最小尺寸
33+
* dragStartBehavior: 确定处理拖动开始行为的方式

lib/widget/form/index.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import 'package:efox_flutter/store/objects/widget_info.dart';
22
import 'checkbox/index.dart' as CheckBox;
33
import 'checkboxlisttile/index.dart' as CheckboxListTile;
44
import 'slider/index.dart' as Slider;
5+
import 'switch/index.dart' as switchExample;
6+
import 'switchlisttile/index.dart' as switchListTile;
57
import 'textinput/index.dart' as textinput;
68
import 'textfield/index.dart' as textfield;
7-
import 'switch/index.dart' as switchExample;
89
import 'rawkeyboard/index.dart' as rawkeyboard;
910
import 'radio/index.dart' as radio;
1011
import 'formfield/index.dart' as formfield;
@@ -29,6 +30,16 @@ List widgets = [
2930
code: 60229, // golf_course
3031
title: Slider.Index.title
3132
),
33+
ItemInfo(
34+
widget: switchExample.Index(),
35+
code: 58706, // local_pizza
36+
title: switchExample.Index.title
37+
),
38+
ItemInfo(
39+
widget: switchListTile.Index(),
40+
code: 57955, // monetization_on
41+
title: switchListTile.Index.title
42+
),
3243
ItemInfo(
3344
widget: daypicker.Index(),
3445
code: 58345, // gradient
@@ -54,11 +65,6 @@ List widgets = [
5465
code: 58698, // local_laundry_service
5566
title: rawkeyboard.Index.title
5667
),
57-
ItemInfo(
58-
widget: switchExample.Index(),
59-
code: 58706, // local_pizza
60-
title: switchExample.Index.title
61-
),
6268
ItemInfo(
6369
widget: textfield.Index(),
6470
code: 58715, // map
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+
3+
class Index extends StatefulWidget {
4+
@override
5+
State<StatefulWidget> createState() => _IndexState();
6+
}
7+
8+
class _IndexState extends State<Index> {
9+
bool _switchValue = false;
10+
@override
11+
void initState() {
12+
super.initState();
13+
}
14+
15+
@override
16+
Widget build(BuildContext context) {
17+
return Scaffold(
18+
appBar: AppBar(
19+
title: Text('SwitchListTile'),
20+
),
21+
body: Center(
22+
child: Text('data')
23+
),
24+
);
25+
}
26+
}
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 = 'SwitchListTile';
7+
static String mdUrl = 'docs/widget/form/switchlisttile/index.md';
8+
static String originCodeUrl = 'https://docs.flutter.io/flutter/material/SwitchListTile-class.html';
9+
10+
@override
11+
_IndexState createState() => new _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: [
22+
Demo.Index(),
23+
],
24+
);
25+
}
26+
}

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ flutter:
9595
- docs/widget/form/radio/
9696
- docs/widget/form/rawkeyboard/
9797
- docs/widget/form/switch/
98+
- docs/widget/form/switchlisttile/
9899
- docs/widget/form/textfield/
99100
- docs/widget/form/textinput/
100101
- docs/widget/navigator/appbar/

0 commit comments

Comments
 (0)