round_check_box.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import 'package:flutter/material.dart';
  2. class RoundCheckBox extends StatefulWidget {
  3. bool value = false;
  4. final double size;
  5. final Color activeColor;
  6. final Color defaultColor;
  7. final Function(bool) onChanged;
  8. RoundCheckBox({Key key, @required this.value, this.onChanged, this.size,
  9. this.activeColor = Colors.white, this.defaultColor = Colors.white }) : super(key: key);
  10. @override
  11. _RoundCheckBoxState createState() => _RoundCheckBoxState();
  12. }
  13. class _RoundCheckBoxState extends State<RoundCheckBox> {
  14. @override
  15. Widget build(BuildContext context) {
  16. return Center(
  17. child: GestureDetector(
  18. onTap: () {
  19. widget.value = !widget.value;
  20. widget.onChanged(widget.value);
  21. },
  22. child: Padding(
  23. padding: const EdgeInsets.all(10.0),
  24. child: widget.value ? Icon(
  25. Icons.check_circle,
  26. size: widget.size,
  27. color: widget.activeColor,
  28. ) : Icon(
  29. Icons.panorama_fish_eye,
  30. size: widget.size,
  31. color: widget.defaultColor,
  32. ),
  33. )),
  34. );
  35. }
  36. }