ControlledStarRating constructor
const
ControlledStarRating({
- Key? key,
- StarRatingController? controller,
- double initialValue = 0.0,
- ValueChanged<
double> ? onChanged, - bool enabled = true,
- double step = 0.5,
- Axis direction = Axis.horizontal,
- double max = 5.0,
- Color? activeColor,
- Color? backgroundColor,
- double starPoints = 5,
- double? starSize,
- double? starSpacing,
- double? starPointRounding,
- double? starValleyRounding,
- double? starSquash,
- double? starInnerRadiusRatio,
- 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 controllerinitialValue(double, default: 0.0): starting rating when no controlleronChanged(ValueChangedenabled(bool, default: true): whether star rating is interactivestep(double, default: 0.5): minimum increment for rating changesdirection(Axis, default: horizontal): layout direction of starsmax(double, default: 5.0): maximum rating valueactiveColor(Color?, optional): color of filled star portionsbackgroundColor(Color?, optional): color of unfilled star portionsstarPoints(double, default: 5): number of points per starstarSize(double?, optional): override size of each starstarSpacing(double?, optional): override spacing between starsstarPointRounding(double?, optional): rounding radius for star pointsstarValleyRounding(double?, optional): rounding radius for star valleysstarSquash(double?, optional): vertical compression factorstarInnerRadiusRatio(double?, optional): inner to outer radius ratiostarRotation(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,
});