PannableRatingBar class

A StatelessWidget rating bar that supports tap, pan (drag) and hover events, with no limits on the value of PannableRatingBar.rate. The value is distributed to each RatingWidget.child respectively. The value is reported through the PannableRatingBar.onChanged callback for tap or drag event and can be used as desired. Similarly, the value is reported through the PannableRatingBar.onHover callback for hover event and can be used as desired. This widget uses Flutter's Wrap layout and supports all its properties. For more information on these properties, refer to the Wrap documentation. It also takes Wrap.textDirection and Wrap.verticalDirection into account during drawing.

Inheritance

Constructors

PannableRatingBar({Key? key, required double rate, required List<RatingWidget> items, ValueChanged<double>? onChanged, ValueChanged<double>? onHover, Axis direction = Axis.horizontal, WrapAlignment alignment = WrapAlignment.center, double spacing = 0, WrapAlignment runAlignment = WrapAlignment.center, double runSpacing = 0, WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start, TextDirection? textDirection, VerticalDirection verticalDirection = VerticalDirection.down, Clip clipBehavior = Clip.none, bool enablePixelsCompensation = true, double? minRating, double? maxRating, GestureType gestureType = GestureType.tapAndDrag, ValueChanged<double>? onCompleted, RatingValueTransformer valueTransformer = singleFractionalValueTransformer})
Constructs a PannableRatingBar widget with a required rate and a list of RatingWidget items. If multiple items have similar features, consider using PannableRatingBar.builder. The items do not have to be the same, and each item can have its own unique size, shape, etc.
const
PannableRatingBar.builder({Key? key, required double rate, required IndexedRatingWidgetBuilder itemBuilder, required int itemCount, ValueChanged<double>? onChanged, ValueChanged<double>? onHover, Axis direction = Axis.horizontal, WrapAlignment alignment = WrapAlignment.center, double spacing = 0, WrapAlignment runAlignment = WrapAlignment.center, double runSpacing = 0, WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start, TextDirection? textDirection, VerticalDirection verticalDirection = VerticalDirection.down, Clip clipBehavior = Clip.none, bool enablePixelsCompensation = true, double? minRating, double? maxRating, GestureType gestureType = GestureType.tapAndDrag, ValueChanged<double>? onCompleted, RatingValueTransformer valueTransformer = singleFractionalValueTransformer})
Construct a PannableRatingBar using a builder function. This constructor allows you to generate each item on-demand, which can be useful if many of the items are similar. The items generated by itemBuilder can have different size, shape, etc.
const

Properties

alignment WrapAlignment
Refer to Wrap.alignment
final
clipBehavior Clip
Refer to Wrap.clipBehavior
final
crossAxisAlignment WrapCrossAlignment
Refer to Wrap.crossAxisAlignment
final
direction Axis
Refer to Wrap.direction
final
enablePixelsCompensation bool
A flag to determine whether the child widgets will have a margin of 1px or not. This is a workaround for an issue in Flutter (https://github.com/flutter/flutter/issues/98464).
final
gestureType GestureType
Specifies the gesture PannableRatingBar.onChanged will respond to. Default to GestureType.tapAndDrag.
final
hashCode int
The hash code for this object.
no setterinherited
itemCount int
Retrieves the current number of RatingWidgets in this rating bar.
no setter
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxRating double?
The maximum value to be considered when callbacks are fired. The callbacks will be skipped if the incoming value is bigger than maxRating.
final
minRating double?
The minimum value to be considered when callbacks are fired. The callbacks will be skipped if the incoming value is smaller than minRating.
final
onChanged ValueChanged<double>?
The callback is triggered each time there's a new value of rate that is received through a tap or drag pointer event. This callback only reports the next value, to actually change the visual appearance of the widget, it needs to be rebuilt with the new rate value.
final
onCompleted ValueChanged<double>?
The callback function that is triggered when the user has completed the rating process, after a touch or drag event has ended. The callback will emit the rate value at the position where the pointer was released. This can be used to get the final rating selected by the user.
final
onHover ValueChanged<double>?
The callback is triggered whenever the mouse hovers over the rating widgets. It reports the rate value at that pointer position. This callback only reports the next value, to actually change the visual appearance of the widget, it needs to be rebuilt with the new rate value.
final
rate double
The current rating value of this widget, which will be correctly distributed for all RatingWidget.child children.
final
runAlignment WrapAlignment
Refer to Wrap.runAlignment
final
runSpacing double
Refer to Wrap.runSpacing
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
spacing double
Refer to Wrap.spacing
final
textDirection TextDirection?
Refer to Wrap.textDirection
final
valueTransformer RatingValueTransformer
Transformer that will mutate the original rating value. Return null will prevent the rating value from being fired in callbacks. Default to singleFractionalValueTransformer, which will round to the nearest single digit. For rounding to the nearest .5, consider halfFractionalValueTransformer, or rawValueTransformer to leave the value as is.
final
verticalDirection VerticalDirection
Refer to Wrap.verticalDirection
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
calcPercent(int index, double rate) double
Calculates the distribution of the rate value among each of the RatingWidgets
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}) 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