Flutter Widget之Switch

Widget:https://flutter.io/docs/development/ui/widgets
Switch:https://docs.flutter.io/flutter/material/Switch-class.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import 'package:flutter/material.dart';

class SwitchDemoPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new _SwitchDemoPageState();
}
}

class _SwitchDemoPageState extends State<SwitchDemoPage> {
bool check = true;

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: Text('Switch Demo'),
),
body: Center(
/*
activeColor → Color - 激活时原点的颜色
activeThumbImage → ImageProvider - 原点还支持图片,激活时的效果
activeTrackColor → Color - 激活时横条的颜色
inactiveThumbColor → Color - 非激活时原点的颜色
inactiveThumbImage → ImageProvider - 非激活原点的图片效果
inactiveTrackColor → Color - 非激活时横条的颜色
onChanged → ValueChanged - 改变时触发
value → bool - 切换按钮的值
*/
child: new Switch(
value: this.check,
activeColor: Colors.blue, // 激活时原点颜色
onChanged: (bool val) {
this.setState(() {
this.check = !this.check;
});
},
)
)
);
}
}

Flutter Widget Switch

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :