File tree Expand file tree Collapse file tree 3 files changed +50
-4
lines changed Expand file tree Collapse file tree 3 files changed +50
-4
lines changed Original file line number Diff line number Diff line change 1- ## ** 文档完善中**
1+ ## ** Switch**
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: 确定处理拖动开始行为的方式
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ class Index extends StatefulWidget {
66}
77
88class _IndexState extends State <Index > {
9+ bool _switchValue = false ;
910 @override
1011 void initState () {
1112 super .initState ();
@@ -18,7 +19,20 @@ class _IndexState extends State<Index> {
1819 title: Text ('Switch' ),
1920 ),
2021 body: Center (
21- child: Text ('更新中' ),
22+ child: Switch (
23+ value: _switchValue,
24+ onChanged: (value){
25+ setState (() {
26+ _switchValue = value;
27+ });
28+ },
29+ activeColor: Theme .of (context).primaryColor,
30+ activeTrackColor: Theme .of (context).primaryColor.withOpacity (0.3 ),
31+ inactiveThumbColor: Colors .black87,
32+ inactiveTrackColor: Colors .black12,
33+ activeThumbImage: NetworkImage ('http://pic1.win4000.com/wallpaper/2019-02-15/5c664c4b4dc2f.jpg' ),
34+ inactiveThumbImage: NetworkImage ('http://pic1.win4000.com/wallpaper/2019-02-14/5c651084373de.jpg' ,),
35+ ),
2236 ),
2337 );
2438 }
Original file line number Diff line number Diff line change 11import 'package:flutter/material.dart' ;
22import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
3- // import 'demo.dart' as Demo;
3+ import 'demo.dart' as Demo;
44
55class Index extends StatefulWidget {
66 static String title = 'Switch' ;
@@ -19,7 +19,7 @@ class _IndexState extends State<Index> {
1919 originCodeUrl: Index .originCodeUrl,
2020 mdUrl: Index .mdUrl,
2121 demoChild: [
22- // Demo.Index(),
22+ Demo .Index (),
2323 ],
2424 );
2525 }
You can’t perform that action at this time.
0 commit comments