Files
FlutterUnit/lib/views/widgets/StatefulWidget/Checkbox/node1_base.dart
2020-05-03 23:05:53 +08:00

44 lines
1.2 KiB
Dart
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
/// create by 张风捷特烈 on 2020-03-29
/// contact me by email 1981462002@qq.com
/// 说明:
// {
// "widgetId": 39,
// "name": 'Checkbox基础用法',
// "priority": 1,
// "subtitle":
// "【value】 : 是否选中 【double】\n"
// "【checkColor】: 选中时✔gou颜色 【Color】\n"
// "【activeColor】: 选中时框内颜色 【Color】\n"
// "【onChanged】: 状态改变事件 【Function(bool)】\n",
// }
class CustomCheckbox extends StatefulWidget {
@override
_CustomCheckboxState createState() => _CustomCheckboxState();
}
class _CustomCheckboxState extends State<CustomCheckbox> {
bool _checked = false;
final colors = [Colors.red, Colors.yellow, Colors.blue, Colors.green];
@override
Widget build(BuildContext context) {
return Wrap(
spacing: 10,
children: colors
.map((e) =>
Checkbox(
value: _checked,
checkColor: Colors.white,
activeColor: e,
onChanged: (v) =>
setState(() => _checked = v)))
.toList(),
);
}
}