checkbox method

Widget checkbox(
  1. bool isSelected,
  2. dynamic onChange(
    1. bool
    ),
  3. BuildContext context, {
  4. Color? color,
  5. Color? borderColor,
})

Implementation

Widget checkbox(
    bool isSelected, Function(bool) onChange, BuildContext context, {Color? color, Color? borderColor}) {
  var size = 26.0;
  return Material(
    borderRadius: BorderRadius.circular(DUI.spacing.smallBorderRadius + 4),
    clipBehavior: Clip.antiAliasWithSaveLayer,
    color: Colors.transparent,
    child: InkWell(
        child: Container(
          width: size,
          height: size,
          color: Colors.transparent,
          child: Stack(
            alignment: Alignment.center,
            children: [
              Container(
                  width: size - 4,
                  height: size - 4,
                  decoration: BoxDecoration(
                    color: Colors.transparent,
                    borderRadius: BorderRadius.circular(6),
                    border: Border.all(
                        color: borderColor ?? Theme.of(context).textTheme.bodyMedium!.color!,
                        width: 2.0),
                  )),
              isSelected
                  ? Container(
                      width: size - 14,
                      height: size - 14,
                      decoration: BoxDecoration(
                        color: color ?? Theme.of(context).colorScheme.primary,
                        borderRadius: BorderRadius.circular(2),
                      ))
                  : SizedBox.shrink(),
            ],
          ),
        ),
        onTap: () {
          onChange(!isSelected);
        }),
  );
}