| 1 | import 'package:flutter/material.dart'; |
| 2 | |
| 3 | class SimpleCheckbox extends StatefulWidget { |
| 4 | SimpleCheckbox({this.onChanged}); |
| 5 | |
| 6 | final Function(bool)? onChanged; |
| 7 | |
| 8 | @override |
| 9 | State<SimpleCheckbox> createState() => _SimpleCheckboxState(); |
| 10 | } |
| 11 | |
| 12 | class _SimpleCheckboxState extends State<SimpleCheckbox> { |
| 13 | bool initialValue = false; |
| 14 | |
| 15 | @override |
| 16 | Widget build(BuildContext context) { |
| 17 | return SizedBox( |
| 18 | height: 24.0, |
| 19 | width: 24.0, |
| 20 | child: Checkbox( |
| 21 | value: initialValue, |
| 22 | onChanged: (value) => setState(() { |
| 23 | initialValue = value!; |
| 24 | widget.onChanged?.call(value); |
| 25 | }), |
| 26 | checkColor: Theme.of(context).textTheme.titleLarge!.color, |
| 27 | activeColor: Colors.transparent, |
| 28 | materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, |
| 29 | side: WidgetStateBorderSide.resolveWith((states) => |
| 30 | BorderSide(color: Theme.of(context).textTheme.titleLarge!.color!, width: 1.0)), |
| 31 | ), |
| 32 | ); |
| 33 | } |
| 34 | } |