defaultContentBuilder static method

Widget Function(String title, String? subTitle, String? imageUrl, bool isSelected, bool isDisabled) defaultContentBuilder(
  1. ColorScheme colors
)

Implementation

static Widget Function(
  String title,
  String? subTitle,
  String? imageUrl,
  bool isSelected,
  bool isDisabled,
) defaultContentBuilder(ColorScheme colors) {
  return (title, subTitle, imageUrl, isSelected, isDisabled) {
    final titleColor = isDisabled
        ? colors.onSurface.o(0.38)
        : isSelected
            ? colors.primary
            : colors.onSurface;

    final textContent = Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisSize: MainAxisSize.min,
      children: [
        Text(
          title,
          style: TextStyle(fontSize: 14, color: titleColor, fontWeight: isSelected ? FontWeight.w500 : FontWeight.w400),
          overflow: TextOverflow.ellipsis,
          maxLines: 1,
        ),
        if (subTitle != null) const SizedBox(height: 2.5),
        if (subTitle != null)
          Text(
            subTitle,
            style: TextStyle(fontSize: 12.0, color: isDisabled ? colors.onSurface.o(0.38) : colors.onSurfaceVariant),
            overflow: TextOverflow.ellipsis,
            maxLines: 1,
          ),
      ],
    );

    Widget child;
    if (!imageUrl.isNullOrBlank) {
      child = Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          TImage(
            url: imageUrl,
            size: 45,
            backgroundColor: colors.surfaceDim,
            disabled: true,
          ),
          const SizedBox(width: 15),
          Expanded(child: textContent),
        ],
      );
    } else {
      child = textContent;
    }

    return child;
  };
}