buildStructuredContent static method
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,
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();
}