You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.6 KiB

3 years ago
import 'package:aku_new_community/base/base_style.dart';
import 'package:aku_new_community/utils/headers.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class BeeCheckBox extends StatefulWidget {
4 years ago
final Function(bool)? onChange;
final bool? isRound;
final double? size;
3 years ago
4 years ago
BeeCheckBox({Key? key, this.onChange, this.isRound, this.size})
: super(key: key);
3 years ago
4 years ago
BeeCheckBox.round({Key? key, this.onChange, this.size})
: this.isRound = true,
super(key: key);
3 years ago
@override
_BeeCheckBoxState createState() => _BeeCheckBoxState();
}
class _BeeCheckBoxState extends State<BeeCheckBox> {
double get boxSize => widget.size ?? 28.w;
bool _isSelect = false;
3 years ago
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
_isSelect = !_isSelect;
setState(() {});
4 years ago
widget.onChange!(_isSelect);
},
child: AnimatedContainer(
duration: Duration(milliseconds: 300),
decoration: BoxDecoration(
border: Border.all(
width: 1.w, color: _isSelect ? kPrimaryColor : kDarkSubColor),
color: _isSelect ? kPrimaryColor : Colors.transparent,
borderRadius:
4 years ago
BorderRadius.circular(widget.isRound! ? boxSize / 2 : 0)),
curve: Curves.easeInOutCubic,
width: boxSize,
height: boxSize,
child: _isSelect
? Icon(
CupertinoIcons.check_mark,
size: 25.w,
color: Colors.white,
)
: SizedBox(),
),
);
}
}