PrismRating class

A star rating that is operable without sight and without a mouse.

Tapping the middle of a star picks the half value, so a 5-star control gives ten possible scores without a fiddly drag. Each star is an individual button-in-a-row with an explicit label, and the whole control is a slider to a screen reader, so the score can be read and changed with a swipe.

PrismRating(
  value: rating,
  onChanged: (next) => setState(() => rating = next),
  label: 'How was the delivery?',
)
Inheritance

Constructors

PrismRating({Key? key, required double value, ValueChanged<double>? onChanged, int max = 5, bool allowHalf = false, double? size, Color? color, String? label, String? readOnlyLabel, bool showValue = false, PrismSemantic semantic = PrismSemantic.warning})
Creates a rating control.
const

Properties

allowHalf → bool
Whether half-star precision is selectable by tapping the left half.
final
color → Color?
Star colour. Defaults to the semantic accent.
final
hashCode → int
The hash code for this object.
no setterinherited
isReadOnly → bool
Whether the control can be changed.
no setter
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label → String?
Accessible name for the control, e.g. "How was the delivery?".
final
max → int
Number of stars.
final
onChanged → ValueChanged<double>?
Called with the new score. When null the control is read-only.
final
readOnlyLabel → String?
Accessible label for a read-only rating. Defaults to "Rated <value> out of <max>".
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semantic → PrismSemantic
Which semantic role colours the filled stars.
final
showValue → bool
Whether to show the numeric score beside the stars.
final
size → double?
Star size. Defaults to PrismTokens.spaceLg.
final
value → double
The current score. Clamped to 0..max.
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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