build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Describes the part of the UI represented by this widget.

Implementation

@override
Widget build(BuildContext context) {
  final interactive = enabled && onChanged != null;
  final control = Checkbox(
    value: value,
    onChanged: interactive ? onChanged : null,
    enabled: enabled,
  );

  return ListTile(
    title: title,
    subtitle: subtitle,
    leading: controlAffinity == ListTileControlAffinity.leading
        ? control
        : secondary,
    trailing: controlAffinity == ListTileControlAffinity.trailing
        ? control
        : secondary,
    selected: selected,
    dense: dense,
    enabled: enabled,
    padding: contentPadding,
    onTap: interactive
        ? () {
            return onChanged?.call(!value);
          }
        : null,
  );
}