FormeCupertinoSegmentedControl<T extends Object> constructor

FormeCupertinoSegmentedControl<T extends Object>({
  1. Key? key,
  2. String? name,
  3. T? initialValue,
  4. FormeAsyncValidator<T?>? asyncValidator,
  5. Duration? asyncValidatorDebounce,
  6. AutovalidateMode? autovalidateMode,
  7. FormeFieldDecorator<T?>? decorator,
  8. bool enabled = true,
  9. FocusNode? focusNode,
  10. FormeFieldInitialized<T?>? onInitialized,
  11. FormeFieldSetter<T?>? onSaved,
  12. FormeFieldStatusChanged<T?>? onStatusChanged,
  13. int? order,
  14. bool quietlyValidate = false,
  15. bool readOnly = false,
  16. bool requestFocusOnUserInteraction = true,
  17. FormeFieldValidationFilter<T?>? validationFilter,
  18. FormeValidator<T?>? validator,
  19. required Map<T, Widget> children,
  20. Color? borderColor,
  21. Color? disableBorderColor,
  22. Color? disableSelectedColor,
  23. Color? disableUnselectedColor,
  24. EdgeInsetsGeometry? padding,
  25. Color? pressedColor,
  26. Color? selectedColor,
  27. Color? unselectedColor,
})

Implementation

FormeCupertinoSegmentedControl({
  super.key,
  super.name,
  super.initialValue,
  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,
  required this.children,
  this.borderColor,
  this.disableBorderColor,
  this.disableSelectedColor,
  this.disableUnselectedColor,
  this.padding,
  this.pressedColor,
  this.selectedColor,
  this.unselectedColor,
}) : super.allFields(builder: (state) {
        final bool readOnly = state.readOnly;
        return Focus(
          focusNode: state.focusNode,
          //still now way to disable CupertinoSegmentedControl officially after 3 years....
          child: IgnorePointer(
            ignoring: readOnly,
            child: CupertinoSegmentedControl<T>(
                groupValue: state.value,
                children: children,
                unselectedColor:
                    readOnly ? disableUnselectedColor : unselectedColor,
                selectedColor:
                    readOnly ? disableSelectedColor : selectedColor,
                borderColor: readOnly ? disableBorderColor : borderColor,
                pressedColor: pressedColor,
                padding: padding,
                onValueChanged: (v) {
                  state.didChange(v);
                  state.requestFocusOnUserInteraction();
                }),
          ),
        );
      });