flutter Checkbox 复选框组件
import 'package:flutter/material.dart'; class CheckboxDemo extends StatefulWidget { @override _CheckboxDemoState createState() => _CheckboxDemoState(); } class _CheckboxDemoState extends State<CheckboxDemo> { bool _checkboxItemA = true; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('CheckboxDemo'), elevation: 0.0, ), body: Container( padding: EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ CheckboxListTile( value: _checkboxItemA, onChanged: (value) { setState(() { _checkboxItemA = value; }); }, title: Text('Checkbox Item A'), subtitle: Text('Description'), secondary: Icon(Icons.bookmark), selected: _checkboxItemA, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ // Checkbox( // value: _checkboxItemA, // onChanged: (value) { // setState(() { // _checkboxItemA = value; // }); // }, // activeColor: Colors.black, // ), ], ), ], ), ) ); } }
文档:https://api.flutter.dev/flutter/material/Checkbox-class.html
效果:
最后,关注【码上加油站】微信公众号后,有疑惑有问题想加油的小伙伴可以码上加入社群,让我们一起码上加油吧!!!
posted on 2019-08-13 11:36 LoaderMan 阅读(1551) 评论(0) 编辑 收藏 举报