checkboxTitleBuilder function

Widget? checkboxTitleBuilder(
  1. FastCheckboxState field
)

A FastCheckboxWidgetBuilder that is the default FastCheckbox.titleBuilder.

Returns a Text widget when FastCheckbox.titleText is a String otherwise null.

Implementation

Widget? checkboxTitleBuilder(FastCheckboxState field) {
  final FastCheckboxState(:value!) = field;
  final FastCheckbox(:titleText) = field.widget;
  final theme = Theme.of(field.context);
  final color = theme.textTheme.titleMedium?.color ?? Colors.black;

  if (titleText is String) {
    return Text(
      titleText,
      style: TextStyle(
        color: value ? color : theme.disabledColor,
      ),
    );
  }

  return null;
}