buildStructuredContent static method

Widget buildStructuredContent({
  1. String? title,
  2. double? titleFontSize,
  3. FontWeight? titleFontWeight,
  4. Color? titleColor,
  5. String? titleFontFamily,
  6. ContentAlignment titleAlignment = ContentAlignment.left,
  7. int? titleMaxLines,
  8. TextOverflow? titleOverflow,
  9. String? description,
  10. double? descriptionFontSize,
  11. FontWeight? descriptionFontWeight,
  12. Color? descriptionColor,
  13. String? descriptionFontFamily,
  14. ContentAlignment descriptionAlignment = ContentAlignment.left,
  15. int? descriptionMaxLines,
  16. TextOverflow? descriptionOverflow,
  17. double? rating,
  18. int maxRating = 5,
  19. double ratingStarSize = 16.0,
  20. Color? ratingFilledColor,
  21. Color? ratingEmptyColor,
  22. bool showRatingNumber = true,
  23. String? customRatingText,
  24. ValueChanged<double>? onRatingChanged,
  25. List<String>? chips,
  26. ContentChipPosition chipPosition = ContentChipPosition.afterTitle,
  27. Color? chipBackgroundColor,
  28. Color? chipTextColor,
  29. double? chipFontSize,
  30. FontWeight? chipFontWeight,
  31. double? chipBorderRadius,
  32. VoidCallback? onChipTap,
  33. List<ContentChip>? customChips,
  34. List<MetricItem>? metrics,
  35. int metricsColumns = 3,
  36. double metricsSpacing = 16.0,
  37. bool showMetricsDividers = false,
  38. Color? metricsBackgroundColor,
  39. List<IconTextPair>? iconTextPairs,
  40. String? price,
  41. double? priceFontSize,
  42. FontWeight? priceFontWeight,
  43. Color? priceColor,
  44. ContentAlignment priceAlignment = ContentAlignment.left,
  45. double contentSpacing = 8.0,
})

Implementation

static Widget buildStructuredContent({
  String? title,
  double? titleFontSize,
  FontWeight? titleFontWeight,
  Color? titleColor,
  String? titleFontFamily,
  ContentAlignment titleAlignment = ContentAlignment.left,
  int? titleMaxLines,
  TextOverflow? titleOverflow,

  String? description,
  double? descriptionFontSize,
  FontWeight? descriptionFontWeight,
  Color? descriptionColor,
  String? descriptionFontFamily,
  ContentAlignment descriptionAlignment = ContentAlignment.left,
  int? descriptionMaxLines,
  TextOverflow? descriptionOverflow,

  double? rating,
  int maxRating = 5,
  double ratingStarSize = 16.0,
  Color? ratingFilledColor,
  Color? ratingEmptyColor,
  bool showRatingNumber = true,
  String? customRatingText,
  ValueChanged<double>? onRatingChanged,

  List<String>? chips,
  ContentChipPosition chipPosition = ContentChipPosition.afterTitle,
  Color? chipBackgroundColor,
  Color? chipTextColor,
  double? chipFontSize,
  FontWeight? chipFontWeight,
  double? chipBorderRadius,
  VoidCallback? onChipTap,
  List<ContentChip>? customChips,

  List<MetricItem>? metrics,
  int metricsColumns = 3,
  double metricsSpacing = 16.0,
  bool showMetricsDividers = false,
  Color? metricsBackgroundColor,

  List<IconTextPair>? iconTextPairs,

  String? price,
  double? priceFontSize,
  FontWeight? priceFontWeight,
  Color? priceColor,
  ContentAlignment priceAlignment = ContentAlignment.left,

  double contentSpacing = 8.0,
}) {
  List<Widget> contentChildren = [];

  if (chipPosition == ContentChipPosition.beforeTitle && (chips != null || customChips != null)) {
    contentChildren.add(_buildChipsSection(
      chips: chips,
      customChips: customChips,
      chipBackgroundColor: chipBackgroundColor,
      chipTextColor: chipTextColor,
      chipFontSize: chipFontSize,
      chipFontWeight: chipFontWeight,
      chipBorderRadius: chipBorderRadius,
      onChipTap: onChipTap,
    ));
    contentChildren.add(SizedBox(height: contentSpacing));
  }

  if (title != null) {
    if (chipPosition == ContentChipPosition.rightOfTitle && (chips != null || customChips != null)) {
      contentChildren.add(
        Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Expanded(child: _buildTitle(
              text: title,
              fontSize: titleFontSize,
              fontWeight: titleFontWeight,
              color: titleColor,
              fontFamily: titleFontFamily,
              alignment: titleAlignment,
              maxLines: titleMaxLines,
              overflow: titleOverflow,
            )),
            SizedBox(width: 8),
            _buildChipsSection(
              chips: chips,
              customChips: customChips,
              chipBackgroundColor: chipBackgroundColor,
              chipTextColor: chipTextColor,
              chipFontSize: chipFontSize,
              chipFontWeight: chipFontWeight,
              chipBorderRadius: chipBorderRadius,
              onChipTap: onChipTap,
            ),
          ],
        ),
      );
    } else {
      contentChildren.add(_buildTitle(
        text: title,
        fontSize: titleFontSize,
        fontWeight: titleFontWeight,
        color: titleColor,
        fontFamily: titleFontFamily,
        alignment: titleAlignment,
        maxLines: titleMaxLines,
        overflow: titleOverflow,
      ));
    }
    contentChildren.add(SizedBox(height: contentSpacing));
  }

  if (chipPosition == ContentChipPosition.afterTitle && (chips != null || customChips != null)) {
    contentChildren.add(_buildChipsSection(
      chips: chips,
      customChips: customChips,
      chipBackgroundColor: chipBackgroundColor,
      chipTextColor: chipTextColor,
      chipFontSize: chipFontSize,
      chipFontWeight: chipFontWeight,
      chipBorderRadius: chipBorderRadius,
      onChipTap: onChipTap,
    ));
    contentChildren.add(SizedBox(height: contentSpacing));
  }

  if (description != null) {
    contentChildren.add(_buildDescription(
      text: description,
      fontSize: descriptionFontSize,
      fontWeight: descriptionFontWeight,
      color: descriptionColor,
      fontFamily: descriptionFontFamily,
      alignment: descriptionAlignment,
      maxLines: descriptionMaxLines,
      overflow: descriptionOverflow,
    ));
    contentChildren.add(SizedBox(height: contentSpacing));
  }

  if (rating != null) {
    contentChildren.add(_buildRating(
      rating: rating,
      maxRating: maxRating,
      ratingStarSize: ratingStarSize,
      ratingFilledColor: ratingFilledColor,
      ratingEmptyColor: ratingEmptyColor,
      showRatingNumber: showRatingNumber,
      customRatingText: customRatingText,
      onRatingChanged: onRatingChanged,
    ));
    contentChildren.add(SizedBox(height: contentSpacing));
  }

  if (iconTextPairs != null && iconTextPairs.isNotEmpty) {
    contentChildren.add(_buildIconTextPairs(iconTextPairs));
    contentChildren.add(SizedBox(height: contentSpacing));
  }

  if (metrics != null && metrics.isNotEmpty) {
    contentChildren.add(_buildMetricsGrid(
      metrics: metrics,
      metricsColumns: metricsColumns,
      metricsSpacing: metricsSpacing,
      showMetricsDividers: showMetricsDividers,
      metricsBackgroundColor: metricsBackgroundColor,
    ));
    contentChildren.add(SizedBox(height: contentSpacing));
  }

  if (price != null) {
    contentChildren.add(_buildPrice(
      price: price,
      priceFontSize: priceFontSize,
      priceFontWeight: priceFontWeight,
      priceColor: priceColor,
      priceAlignment: priceAlignment,
    ));
  }

  // Remove trailing spacing if exists
  if (contentChildren.isNotEmpty && contentChildren.last is SizedBox) {
    contentChildren.removeLast();
  }

  return contentChildren.isNotEmpty
      ? Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisSize: MainAxisSize.min,
          children: contentChildren,
        )
      : SizedBox.shrink();
}