mahasCheckboxWidget function

Widget mahasCheckboxWidget({
  1. MahasCheckboxModel? controller,
  2. String? label,
  3. void additionalOnChanged(
    1. bool
    )?,
  4. bool readOnly = false,
})

Implementation

Widget mahasCheckboxWidget({
  MahasCheckboxModel? controller,
  String? label,
  void Function(bool)? additionalOnChanged,
  bool readOnly = false,
}) {
  label ??= controller?.label;

  return Row(
    children: [
      Transform.scale(
        scale: MahasDimensions.getInputIconSize() / Checkbox.width,
        child: Obx(
          () => Checkbox(
            focusNode: controller?.focusNode,
            onChanged: readOnly
                ? null
                : (bool? value) {
                    controller?.checked.value = value ?? false;
                    additionalOnChanged
                        ?.call(controller?.checked.value ?? false);
                  },
            value: controller?.checked.value,
            materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
            side: BorderSide(width: 0.5, color: MahasColors.greyColor),
            activeColor: MahasColors.primaryColor,
          ),
        ),
      ),
      if (label != null)
        InkWell(
          child: getCustomText(
            label,
            color: MahasColors.greyColor,
          ),
          onTap: () {
            if (!readOnly) {
              controller?.checked.toggle();
            }
          },
        )
    ],
  );
}