FormeSwitch constructor

FormeSwitch({
  1. Key? key,
  2. String? name,
  3. bool initialValue = false,
  4. FormeAsyncValidator<bool>? asyncValidator,
  5. Duration? asyncValidatorDebounce,
  6. AutovalidateMode? autovalidateMode,
  7. bool enabled = true,
  8. FocusNode? focusNode,
  9. FormeFieldInitialized<bool>? onInitialized,
  10. FormeFieldSetter<bool>? onSaved,
  11. FormeFieldStatusChanged<bool>? onStatusChanged,
  12. int? order,
  13. bool quietlyValidate = false,
  14. bool readOnly = false,
  15. bool requestFocusOnUserInteraction = true,
  16. FormeFieldValidationFilter<bool>? validationFilter,
  17. FormeValidator<bool>? validator,
  18. FormeFieldDecorator<bool>? decorator,
  19. Color? activeColor,
  20. Color? activeTrackColor,
  21. Color? inactiveThumbColor,
  22. Color? inactiveTrackColor,
  23. ImageProvider<Object>? activeThumbImage,
  24. ImageProvider<Object>? inactiveThumbImage,
  25. MaterialStateProperty<Color?>? thumbColor,
  26. MaterialStateProperty<Color?>? trackColor,
  27. DragStartBehavior? dragStartBehavior,
  28. MaterialTapTargetSize? materialTapTargetSize,
  29. Color? focusColor,
  30. Color? hoverColor,
  31. MaterialStateProperty<Color?>? overlayColor,
  32. double? splashRadius,
  33. ImageErrorListener? onActiveThumbImageError,
  34. ImageErrorListener? onInactiveThumbImageError,
  35. bool autofocus = false,
  36. MaterialStateProperty<Icon?>? thumbIcon,
  37. MouseCursor? mouseCursor,
})

Implementation

FormeSwitch({
  super.key,
  super.name,
  super.initialValue = false,
  super.asyncValidator,
  super.asyncValidatorDebounce,
  super.autovalidateMode,
  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,
  super.decorator,
  this.activeColor,
  this.activeTrackColor,
  this.inactiveThumbColor,
  this.inactiveTrackColor,
  this.activeThumbImage,
  this.inactiveThumbImage,
  this.thumbColor,
  this.trackColor,
  this.dragStartBehavior,
  this.materialTapTargetSize,
  this.focusColor,
  this.hoverColor,
  this.overlayColor,
  this.splashRadius,
  this.onActiveThumbImageError,
  this.onInactiveThumbImageError,
  this.autofocus = false,
  this.thumbIcon,
  this.mouseCursor,
}) : super.allFields(
        builder: (state) {
          final bool readOnly = state.readOnly;
          final bool value = state.value;
          return Switch(
            mouseCursor: mouseCursor,
            thumbIcon: thumbIcon,
            value: value,
            onChanged: readOnly
                ? null
                : (_) {
                    state.didChange(!value);
                    state.requestFocusOnUserInteraction();
                  },
            activeColor: activeColor,
            activeTrackColor: activeTrackColor,
            inactiveThumbColor: inactiveThumbColor,
            inactiveTrackColor: inactiveTrackColor,
            activeThumbImage: activeThumbImage,
            inactiveThumbImage: inactiveThumbImage,
            materialTapTargetSize: materialTapTargetSize,
            thumbColor: thumbColor,
            trackColor: trackColor,
            dragStartBehavior: dragStartBehavior ?? DragStartBehavior.start,
            focusColor: focusColor,
            hoverColor: hoverColor,
            overlayColor: overlayColor,
            splashRadius: splashRadius,
            onActiveThumbImageError: onActiveThumbImageError,
            onInactiveThumbImageError: onInactiveThumbImageError,
            focusNode: state.focusNode,
            autofocus: autofocus,
          );
        },
      );