switch and checkbox

Posted braveheart007

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了switch and checkbox相关的知识,希望对你有一定的参考价值。

import ‘package:flutter/material.dart‘;

void main()=>runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}

class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
int _counter=0;
@override
Widget build(BuildContext context) {
return Scaffold(
body:Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SwitchAndCheckBoxTestRoute(),
],
),
),
);
}
}
class SwitchAndCheckBoxTestRoute extends StatefulWidget {
@override
_SwitchAndCheckBoxTestRouteState createState() => _SwitchAndCheckBoxTestRouteState();
}

class _SwitchAndCheckBoxTestRouteState extends State<SwitchAndCheckBoxTestRoute> {
bool _switchSelected=true; //维护单选开关状态
bool _checkboxSelected=true;//维护复选框状态
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Switch(
value: _switchSelected,//当前状态
activeColor: Colors.lime,
inactiveThumbColor: Colors.grey,
activeTrackColor: Colors.deepPurple,
onChanged:(value){
//重新构建页面
setState(() {
_switchSelected=value;
});
},
),
Checkbox(
value: _checkboxSelected,
activeColor: Colors.orange, //选中时的颜色
checkColor: Colors.lightBlue,
onChanged:(value){
setState(() {
_checkboxSelected=value;
});
} ,
)
],
);
}
}

以上是关于switch and checkbox的主要内容,如果未能解决你的问题,请参考以下文章

The Difference Between a Router, Switch and Hub

C#Switch datatype between object and byte[]

问题:如何在kaitai中写`010 switch and if`

[CF1491G]Switch and Flip

SDN实战: Practice SDN/OpenFlow with LINC-Switch and OpenDaylight

Switch between Server Core mode and Server GUI mode in Windows Server 2012 R2