ControlledStarRating constructor

const ControlledStarRating({
  1. Key? key,
  2. StarRatingController? controller,
  3. double initialValue = 0.0,
  4. ValueChanged<double>? onChanged,
  5. bool enabled = true,
  6. double step = 0.5,
  7. Axis direction = Axis.horizontal,
  8. double max = 5.0,
  9. Color? activeColor,
  10. Color? backgroundColor,
  11. double starPoints = 5,
  12. double? starSize,
  13. double? starSpacing,
  14. double? starPointRounding,
  15. double? starValleyRounding,
  16. double? starSquash,
  17. double? starInnerRadiusRatio,
  18. double? starRotation,
})

Creates a ControlledStarRating.

Either controller or onChanged should be provided for interactivity. The widget supports both controller-based and callback-based state management patterns with extensive star appearance customization options.

Parameters:

  • controller (StarRatingController?, optional): external state controller
  • initialValue (double, default: 0.0): starting rating when no controller
  • onChanged (ValueChanged
  • enabled (bool, default: true): whether star rating is interactive
  • step (double, default: 0.5): minimum increment for rating changes
  • direction (Axis, default: horizontal): layout direction of stars
  • max (double, default: 5.0): maximum rating value
  • activeColor (Color?, optional): color of filled star portions
  • backgroundColor (Color?, optional): color of unfilled star portions
  • starPoints (double, default: 5): number of points per star
  • starSize (double?, optional): override size of each star
  • starSpacing (double?, optional): override spacing between stars
  • starPointRounding (double?, optional): rounding radius for star points
  • starValleyRounding (double?, optional): rounding radius for star valleys
  • starSquash (double?, optional): vertical compression factor
  • starInnerRadiusRatio (double?, optional): inner to outer radius ratio
  • starRotation (double?, optional): rotation angle in radians

Example:

ControlledStarRating(
  controller: controller,
  max: 5.0,
  step: 0.1,
  activeColor: Colors.amber,
  backgroundColor: Colors.grey[300],
)

Implementation

const ControlledStarRating({
  super.key,
  this.controller,
  this.initialValue = 0.0,
  this.onChanged,
  this.enabled = true,
  this.step = 0.5,
  this.direction = Axis.horizontal,
  this.max = 5.0,
  this.activeColor,
  this.backgroundColor,
  this.starPoints = 5,
  this.starSize,
  this.starSpacing,
  this.starPointRounding,
  this.starValleyRounding,
  this.starSquash,
  this.starInnerRadiusRatio,
  this.starRotation,
});