CupertinoSwitch是一个开关控件,主要属性如表所示:
其基本用法如下:
class CupertinoSwitchDemo extends StatefulWidget {
@override
State<StatefulWidget> createState() => _CupertinoSwitchDemo();
}
class _CupertinoSwitchDemo extends State<CupertinoSwitchDemo> {
bool _value = true;
@override
Widget build(BuildContext context) {
return Center(
child: CupertinoSwitch(
value: _value,
onChanged: (bool v) {
setState(() {
_value = v;
});
},
activeColor: Colors.red,
),
);
}
}
运行效果如图所示:
酷客网相关文章:
评论前必须登录!
注册