本文主要是介绍Flutter-单选和多选,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
import 'package:flutter/material.dart';//单选和多选 void main() => runApp(MaterialApp(home: _home(),));class _home extends StatefulWidget {@overrideState<StatefulWidget> createState() {// TODO: implement createStatereturn new _homeState();} }class _homeState extends State<_home> {bool _switchSelected = true; //单选状态bool _checkBoxSelected = true; //复选状态@overrideWidget build(BuildContext context) {// TODO: implement buildreturn new Scaffold(appBar: new AppBar(title: Text('title'),centerTitle: true,),body: new Column(children: <Widget>[Switch(value: _switchSelected,activeColor: Colors.red,onChanged: (value) {setState(() {_switchSelected = value;});},),Checkbox(value: _checkBoxSelected,activeColor: Colors.green,onChanged: (value) {setState(() {_checkBoxSelected = value;});},)],),);} }
这篇关于Flutter-单选和多选的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!