UiRating class

Star (or configurable-icon) rating input.

Renders count icons in a row, filled up to value. Pass null to onChanged for a display-only control (e.g. showing an average rating nobody can edit); use readOnly when a callback exists but the value must not change from this widget, and enabled for the fully muted, non-interactive state.

Each icon is its own UiPressable tap target, matching how UiRadioGroup composes multiple UiRadio items rather than reading a single drag gesture across the whole row.

UiRating(
  value: rating,
  allowHalfRating: true,
  label: 'Your rating',
  onChanged: (value) => setState(() => rating = value),
)
Inheritance

Constructors

UiRating({Key? key, required double value, ValueChanged<double>? onChanged, int count = 5, bool allowHalfRating = false, double size = 24, String? label, String? helper, String? errorText, bool enabled = true, bool readOnly = false, String? semanticLabel, IconData? icon, FocusNode? focusNode, bool autofocus = false})
const

Properties

allowHalfRating bool
Whether tapping the left/right half of an icon sets a .5 value instead of always rounding up to the whole icon.
final
autofocus bool
final
count int
Number of icons rendered.
final
enabled bool
Whether the control can be interacted with at all. Disabled renders muted and ignores every input, which is distinct from readOnly.
final
errorText String?
Optional validation error shown below the icons.
final
focusNode FocusNode?
final
hashCode int
The hash code for this object.
no setterinherited
helper String?
Optional helper text shown below the icons when there is no error.
final
icon IconData?
Icon used for filled/empty/partial icons. Defaults to LucideIcons.star.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label String?
Optional label shown above the icons.
final
onChanged ValueChanged<double>?
Called with the new value when the user taps an icon or adjusts it with the keyboard. null renders a display-only control.
final
readOnly bool
Whether the control only displays a value (e.g. an aggregate rating) even though onChanged may be set. Unlike enabled, read-only keeps the normal (non-muted) fill colors — it just can't be changed here.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel String?
Accessibility label announced instead of the generated "Rating: x out of y stars" string.
final
size double
Icon size in logical pixels.
final
value double
Current rating value. Supports half-values (e.g. 3.5) when allowHalfRating is true; otherwise callers should pass whole numbers.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<UiRating>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited