FormBuilderRatingBar constructor Null safety

FormBuilderRatingBar(
  1. {Key? key,
  2. required String name,
  3. FormFieldValidator<double>? validator,
  4. double? initialValue,
  5. InputDecoration decoration = const InputDecoration(),
  6. ValueChanged<double?>? onChanged,
  7. ValueTransformer<double?>? valueTransformer,
  8. bool enabled = true,
  9. FormFieldSetter<double>? onSaved,
  10. AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  11. VoidCallback? onReset,
  12. FocusNode? focusNode,
  13. Color? glowColor,
  14. double? maxRating,
  15. TextDirection? textDirection,
  16. Color? unratedColor,
  17. bool allowHalfRating = false,
  18. Axis direction = Axis.horizontal,
  19. bool glow = true,
  20. double glowRadius = 2,
  21. double initialRating = 0.0,
  22. int itemCount = 5,
  23. EdgeInsetsGeometry itemPadding = EdgeInsets.zero,
  24. double itemSize = 40.0,
  25. double minRating = 0,
  26. bool tapOnlyMode = false,
  27. bool updateOnDrag = false,
  28. WrapAlignment wrapAlignment = WrapAlignment.start,
  29. RatingWidget? ratingWidget}
)

Implementation

FormBuilderRatingBar({
  Key? key,
  //From Super
  required String name,
  FormFieldValidator<double>? validator,
  double? initialValue,
  InputDecoration decoration = const InputDecoration(),
  ValueChanged<double?>? onChanged,
  ValueTransformer<double?>? valueTransformer,
  bool enabled = true,
  FormFieldSetter<double>? onSaved,
  AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  VoidCallback? onReset,
  FocusNode? focusNode,
  this.glowColor,
  this.maxRating,
  this.textDirection,
  this.unratedColor,
  this.allowHalfRating = false,
  this.direction = Axis.horizontal,
  this.glow = true,
  this.glowRadius = 2,
  this.initialRating = 0.0,
  this.itemCount = 5,
  this.itemPadding = EdgeInsets.zero,
  this.itemSize = 40.0,
  this.minRating = 0,
  this.tapOnlyMode = false,
  this.updateOnDrag = false,
  this.wrapAlignment = WrapAlignment.start,
  this.ratingWidget,
}) : super(
        key: key,
        initialValue: initialValue,
        name: name,
        validator: validator,
        valueTransformer: valueTransformer,
        onChanged: onChanged,
        autovalidateMode: autovalidateMode,
        onSaved: onSaved,
        enabled: enabled,
        onReset: onReset,
        decoration: decoration,
        focusNode: focusNode,
        builder: (FormFieldState<double?> field) {
          final state = field as _FormBuilderRatingBarState;
          final widget = state.widget;

          return InputDecorator(
            decoration: state.decoration,
            child: RatingBar(
              initialRating: field.value ?? widget.minRating,
              minRating: widget.minRating,
              direction: widget.direction,
              allowHalfRating: widget.allowHalfRating,
              itemCount: widget.itemCount,
              itemPadding: widget.itemPadding,
              // itemBuilder: widget.itemBuilder
              onRatingUpdate: (rating) {
                state.requestFocus();
                field.didChange(rating);
              },
              ratingWidget: widget.ratingWidget ??
                  RatingWidget(
                    full: const Icon(Icons.star),
                    half: const Icon(Icons.star_half_outlined),
                    empty: const Icon(Icons.star_outline),
                  ),
              glow: widget.glow,
              glowColor: widget.glowColor,
              glowRadius: widget.glowRadius,
              ignoreGestures: !state.enabled,
              itemSize: widget.itemSize,
              maxRating: widget.maxRating,
              tapOnlyMode: widget.tapOnlyMode,
              textDirection: widget.textDirection,
              unratedColor: widget.unratedColor,
              updateOnDrag: widget.updateOnDrag,
              wrapAlignment: widget.wrapAlignment,
            ),
          );
        },
      );