| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import 'package:flutter/material.dart';
- import 'package:twong/utils/index.dart';
- class CircleCheckBox extends StatefulWidget {
- final Color color;
- final bool initValue;
- final Widget child;
- final double size;
- final bool right;
- final Function(bool) onChange;
- CircleCheckBox(this.onChange, {this.initValue = false, this.right = true,
- this.color = Colors.red, this.child, this.size = 20 });
- @override
- State<StatefulWidget> createState() {
- return _CircleCheckBoxState();
- }
- }
- class _CircleCheckBoxState extends State<CircleCheckBox> {
- bool selected = false;
- @override
- Widget build(BuildContext context) {
- return InkWell(
- onTap: () {
- setState(() {
- selected = !selected;
- });
- widget.onChange(selected);
- },
- child: widget.right ? Row(
- children: [
- widget.child,
- Container(
- alignment: Alignment.center,
- margin: EdgeInsets.only(left: 6.px),
- child: selected ? Icon(Icons.radio_button_on, size:
- widget.size, color: widget.color) : Icon(
- Icons.radio_button_off, size: widget.size, color: widget.color),
- )
- ],
- ) : Row(
- children: [
- Container(
- alignment: Alignment.center,
- margin: EdgeInsets.only(right: 6.px),
- child: selected ? Icon(Icons.radio_button_on, size:
- widget.size, color: widget.color) : Icon(
- Icons.radio_button_off, size: widget.size, color: widget.color),
- ),
- widget.child
- ],
- ),
- );
- }
- }
|