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.
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
@immutable
|
|
|
|
class MyCheckbox extends StatelessWidget {
|
|
|
|
final String title;
|
|
|
|
final bool value;
|
|
|
|
final ValueChanged<bool?>? onChanged;
|
|
|
|
final bool enabled = true;
|
|
|
|
final double? maxWidth;
|
|
|
|
|
|
|
|
const MyCheckbox({
|
|
|
|
super.key,
|
|
|
|
required this.title,
|
|
|
|
required this.value,
|
|
|
|
this.onChanged,
|
|
|
|
this.maxWidth,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(maxHeight: 28, maxWidth: maxWidth ?? title.length * 12.0 + 38),
|
|
|
|
child: ListTile(
|
|
|
|
dense: true,
|
|
|
|
title: Text(title, style: const TextStyle(fontSize: 12)),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
horizontalTitleGap: 4,
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|