RatingStars class Null safety

This is a RatingStars widget. it shows a row of stars that describes how many scores a field gets. Star items have an action also that allows use in more cases.

{@tool snippet} Example:

         RatingStars(
            value: value,
            onValueChanged: (v) {
              //
              setState(() {
                value = v;
              });
            },
            starBuilder: (index, color) => Icon(
              Icons.ac_unit_outlined,
              color: color,
            ),
            starCount: 5,
            starSize: 20,
            valueLabelColor: const Color(0xff9b9b9b),
            valueLabelTextStyle: const TextStyle(
                color: Colors.white,
                fontWeight: FontWeight.w400,
                fontStyle: FontStyle.normal,
                fontSize: 12.0),
            valueLabelRadius: 10,
            maxValue: 5,
            starSpacing: 2,
            maxValueVisibility: true,
            valueLabelVisibility: true,
            animationDuration: Duration(milliseconds: 1000),
            valueLabelPadding:
                const EdgeInsets.symmetric(vertical: 1, horizontal: 8),
            valueLabelMargin: const EdgeInsets.only(right: 8),
            starOffColor: const Color(0xffe7e8ea),
            starColor: Colors.yellow,
         )

{@end-tool}

Inheritance

Constructors

RatingStars({Key? key, double value = 0, int starCount = 5, double starSize = 20, Color valueLabelColor = const Color(0xff9b9b9b), TextStyle valueLabelTextStyle = const TextStyle(color: Colors.white, fontWeight: FontWeight.w400, fontStyle: FontStyle.normal, fontSize: 12.0), double valueLabelRadius = 10, double maxValue = 5, double starSpacing = 2, bool maxValueVisibility = true, bool valueLabelVisibility = true, Duration animationDuration = Duration.zero, EdgeInsets valueLabelPadding = const EdgeInsets.symmetric(vertical: 1, horizontal: 8), EdgeInsets valueLabelMargin = const EdgeInsets.only(right: 8), Color starOffColor = const Color(0xffe7e8ea), Color starColor = Colors.yellow, dynamic onValueChanged(double value)?, Widget starBuilder(int index, Color? color)?})
Constructor
const

Properties

animationDuration Duration
animationDuration animated when the value is changed.
final
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
maxValue double
maxValue
final
maxValueVisibility bool
maxValueVisibility show/hide max value in value label at the left side.
final
onValueChanged → (dynamic Function?(double value)?)
onValueChanged if it is not null RatingStars is able to click to change the value, and it is calculated by rounded star count only. Ex: maxValue is 12, starCount is 5, clicked on 3th star, onValueChanged is called with value is 3*12/5=7.2
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
starBuilder → (Widget Function?(int index, Color? color)?)
starBuilder use to build your own star widget. By default, it use a star image from assets.
final
starColor Color
starColor is the color of the star widget that value reaches.
final
starCount int
starCount count of stars, whatever you want.
final
starOffColor Color
starOffColor is the color of the star widget that value doesn't reach yet.
final
starSize double
starSize is size of star widget.
final
starSpacing double
starSpacing is spacing between stars.
final
value double
value is value in 0...maxValue.
final
valueLabelColor Color
valueLabelColor is the color background of label widget.
final
valueLabelMargin EdgeInsets
valueLabelMargin is the margin of label widget.
final
valueLabelPadding EdgeInsets
valueLabelPadding is the padding of the label widget.
final
valueLabelRadius double
valueLabelRadius is the border radius of the label widget.
final
valueLabelTextStyle TextStyle
valueLabelTextStyle is the textStyle of text widget inside the label.
final
valueLabelVisibility bool
valueLabelVisibility show/hide value label at the left side.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
createState() → _RatingStarsState
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. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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}) 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. [...]
@nonVirtual, inherited