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.

32 lines
914 B

import 'package:flutter/material.dart';
class MyCheckbox extends StatelessWidget {
final String title;
final bool value;
final ValueChanged<bool?>? onChanged;
final bool enabled = true;
const MyCheckbox({super.key, required this.title, required this.value, this.onChanged});
@override
Widget build(BuildContext context) {
return ConstrainedBox(
constraints: const BoxConstraints(minHeight: 32),
child: ListTile(
dense: true,
title: Text(title, style: const TextStyle(fontSize: 12)),
contentPadding: EdgeInsets.zero,
leading: Transform.scale(
scale: 0.75,
child: Checkbox(
value: value,
onChanged: enabled ? onChanged : null,
activeColor: enabled ? null : Colors.grey,
),
),
onTap: enabled && onChanged != null ? () => onChanged!(!value) : null,
),
);
}
}