FormeRatingBar constructor
FormeRatingBar({
- Key? key,
- String? name,
- double initialValue = 0,
- FormeAsyncValidator<
double> ? asyncValidator, - Duration? asyncValidatorDebounce,
- AutovalidateMode? autovalidateMode,
- FormeFieldDecorator<
double> ? decorator, - bool enabled = true,
- FocusNode? focusNode,
- FormeFieldInitialized<
double> ? onInitialized, - FormeFieldSetter<
double> ? onSaved, - FormeFieldStatusChanged<
double> ? onStatusChanged, - int? order,
- bool quietlyValidate = false,
- bool readOnly = false,
- bool requestFocusOnUserInteraction = true,
- FormeFieldValidationFilter<
double> ? validationFilter, - FormeValidator<
double> ? validator, - RatingWidget? ratingWidget,
- Color? glowColor,
- double? maxRating,
- TextDirection? textDirection,
- Color? unratedColor,
- bool allowHalfRating = false,
- Axis direction = Axis.horizontal,
- bool glow = true,
- double glowRadius = 2,
- int itemCount = 5,
- EdgeInsets itemPadding = EdgeInsets.zero,
- double itemSize = 40,
- double minRating = 0,
- bool tapOnlyMode = false,
- bool updateOnDrag = false,
- WrapAlignment wrapAlignment = WrapAlignment.start,
- Widget itemBuilder(
- double value,
- BuildContext context,
- int index
Implementation
FormeRatingBar({
super.key,
super.name,
super.initialValue = 0,
super.asyncValidator,
super.asyncValidatorDebounce,
super.autovalidateMode,
super.decorator,
super.enabled = true,
super.focusNode,
super.onInitialized,
super.onSaved,
super.onStatusChanged,
super.order,
super.quietlyValidate = false,
super.readOnly = false,
super.requestFocusOnUserInteraction = true,
super.validationFilter,
super.validator,
this.ratingWidget,
this.glowColor,
this.maxRating,
this.textDirection,
this.unratedColor,
this.allowHalfRating = false,
this.direction = Axis.horizontal,
this.glow = true,
this.glowRadius = 2,
this.itemCount = 5,
this.itemPadding = EdgeInsets.zero,
this.itemSize = 40,
this.minRating = 0,
this.tapOnlyMode = false,
this.updateOnDrag = false,
this.wrapAlignment = WrapAlignment.start,
this.itemBuilder,
}) : super.allFields(
builder: (state) {
final bool readOnly = state.readOnly;
final double value = state.value;
void onRatingUpdate(double value) {
state.didChange(value);
state.requestFocusOnUserInteraction();
}
Widget ratingBar;
if (ratingWidget == null) {
final IndexedWidgetBuilder builder = itemBuilder == null
? (context, _) => const Icon(
Icons.star,
color: Colors.amber,
)
: (context, _) {
return itemBuilder(state.value, context, _);
};
ratingBar = RatingBar.builder(
itemBuilder: builder,
onRatingUpdate: onRatingUpdate,
glowColor: glowColor,
maxRating: maxRating,
textDirection: textDirection,
unratedColor: unratedColor,
allowHalfRating: allowHalfRating,
direction: direction,
glow: glow,
glowRadius: glowRadius,
ignoreGestures: readOnly,
initialRating: value,
itemCount: itemCount,
itemPadding: itemPadding,
itemSize: itemSize,
minRating: minRating,
tapOnlyMode: tapOnlyMode,
updateOnDrag: updateOnDrag,
wrapAlignment: wrapAlignment,
);
} else {
ratingBar = RatingBar(
onRatingUpdate: onRatingUpdate,
ratingWidget: ratingWidget,
glowColor: glowColor,
maxRating: maxRating,
textDirection: textDirection,
unratedColor: unratedColor,
allowHalfRating: allowHalfRating,
direction: direction,
glow: glow,
glowRadius: glowRadius,
ignoreGestures: readOnly,
initialRating: value,
itemCount: itemCount,
itemPadding: itemPadding,
itemSize: itemSize,
minRating: minRating,
tapOnlyMode: tapOnlyMode,
updateOnDrag: updateOnDrag,
wrapAlignment: wrapAlignment,
);
}
return Focus(
focusNode: state.focusNode,
child: ratingBar,
);
},
);