FormeRatingBar constructor

FormeRatingBar({
  1. Key? key,
  2. String? name,
  3. double initialValue = 0,
  4. FormeAsyncValidator<double>? asyncValidator,
  5. Duration? asyncValidatorDebounce,
  6. AutovalidateMode? autovalidateMode,
  7. FormeFieldDecorator<double>? decorator,
  8. bool enabled = true,
  9. FocusNode? focusNode,
  10. FormeFieldInitialized<double>? onInitialized,
  11. FormeFieldSetter<double>? onSaved,
  12. FormeFieldStatusChanged<double>? onStatusChanged,
  13. int? order,
  14. bool quietlyValidate = false,
  15. bool readOnly = false,
  16. bool requestFocusOnUserInteraction = true,
  17. FormeFieldValidationFilter<double>? validationFilter,
  18. FormeValidator<double>? validator,
  19. RatingWidget? ratingWidget,
  20. Color? glowColor,
  21. double? maxRating,
  22. TextDirection? textDirection,
  23. Color? unratedColor,
  24. bool allowHalfRating = false,
  25. Axis direction = Axis.horizontal,
  26. bool glow = true,
  27. double glowRadius = 2,
  28. int itemCount = 5,
  29. EdgeInsets itemPadding = EdgeInsets.zero,
  30. double itemSize = 40,
  31. double minRating = 0,
  32. bool tapOnlyMode = false,
  33. bool updateOnDrag = false,
  34. WrapAlignment wrapAlignment = WrapAlignment.start,
  35. Widget itemBuilder(
    1. double value,
    2. BuildContext context,
    3. 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,
          );
        },
      );