TTableHeader<T, K>.rating constructor

TTableHeader<T, K>.rating(
  1. String text,
  2. double? map(
    1. T
    ), {
  3. int? flex,
  4. double? minWidth,
  5. double? maxWidth,
  6. Alignment? alignment,
  7. int itemCount = 5,
  8. double itemSize = 10.0,
  9. Color? color,
  10. Color? unratedColor,
  11. bool allowHalfRating = false,
  12. double spacing = 0.0,
  13. String? key,
  14. TFilterType? filterType = TFilterType.number,
  15. bool filterable = true,
  16. List<TFilterOperator>? filterOperators,
  17. List? filterItems,
  18. TFilterDef<T>? filterDef,
  19. double widthEstimator(
    1. T data
    )?,
  20. bool flattenOnMobile = false,
  21. String mobileKeyPrefixBuilder(
    1. String headerText,
    2. String childKey
    )?,
  22. List<TKeyValue> keyValuesBuilder(
    1. T data
    )?,
})

Creates a header for displaying ratings.

Implementation

TTableHeader.rating(
  this.text,
  double? Function(T) map, {
  this.flex,
  this.minWidth,
  this.maxWidth,
  this.alignment,
  int itemCount = 5,
  double itemSize = 10.0,
  Color? color,
  Color? unratedColor,
  bool allowHalfRating = false,
  double spacing = 0.0,
  this.key,
  this.filterType = TFilterType.number,
  this.filterable = true,
  this.filterOperators,
  this.filterItems,
  this.filterDef,
  double Function(T data)? widthEstimator,
  this.flattenOnMobile = false,
  this.mobileKeyPrefixBuilder,
  this.keyValuesBuilder,
})  : map = map,
      widthEstimator = widthEstimator ?? ((_) => itemCount * itemSize + (itemCount > 1 ? (itemCount - 1) * spacing : 0.0) + 4.0),
      builder = ((ctx, item, __) {
        final isDense = TTableScope.maybeOf(ctx)?.dense ?? false;
        final ratingValue = map(item.data) ?? 0.0;
        return TRating(
          value: ratingValue,
          itemCount: itemCount,
          itemSize: isDense ? itemSize * 0.8 : itemSize,
          color: color,
          unratedColor: unratedColor,
          disabled: true,
          allowHalfRating: allowHalfRating,
          spacing: spacing,
        );
      });