AnimatedToggleSwitch<T extends Object?>.sizeByHeight constructor

AnimatedToggleSwitch<T extends Object?>.sizeByHeight({
  1. Key? key,
  2. double height = 50.0,
  3. required T current,
  4. required List<T> values,
  5. Duration animationDuration = const Duration(milliseconds: 500),
  6. Curve animationCurve = Curves.easeInOutCirc,
  7. Size indicatorSize = const Size.square(1.0),
  8. SimpleIconBuilder<T>? iconBuilder,
  9. AnimatedIconBuilder<T>? customIconBuilder,
  10. List<Widget>? iconList,
  11. ChangeCallback<T>? onChanged,
  12. double borderWidth = 2.0,
  13. ToggleStyle style = const ToggleStyle(),
  14. StyleBuilder<T>? styleBuilder,
  15. CustomStyleBuilder<T>? customStyleBuilder,
  16. List<ToggleStyle>? styleList,
  17. double selectedIconScale = sqrt2,
  18. Curve iconAnimationCurve = Curves.easeOutBack,
  19. Duration? iconAnimationDuration,
  20. double iconOpacity = 0.5,
  21. double spacing = 0.0,
  22. CustomIndicatorBuilder<T>? foregroundIndicatorIconBuilder,
  23. double selectedIconOpacity = 1.0,
  24. AnimationType iconAnimationType = AnimationType.onSelected,
  25. AnimationType styleAnimationType = AnimationType.onSelected,
  26. AnimationType indicatorAnimationType = AnimationType.onHover,
  27. TapCallback<T>? onTap,
  28. FittingMode fittingMode = FittingMode.preventHorizontalOverlapping,
  29. double minTouchTargetSize = 48.0,
  30. TextDirection? textDirection,
  31. bool iconsTappable = true,
  32. ToggleCursors cursors = const ToggleCursors(),
  33. LoadingIconBuilder<T> loadingIconBuilder = _defaultLoadingIconBuilder,
  34. bool? loading,
  35. Duration? loadingAnimationDuration,
  36. Curve? loadingAnimationCurve,
  37. bool allowUnlistedValues = false,
  38. IndicatorAppearingBuilder indicatorAppearingBuilder = _defaultIndicatorAppearingBuilder,
  39. Duration indicatorAppearingDuration = _defaultIndicatorAppearingAnimationDuration,
  40. Curve indicatorAppearingCurve = _defaultIndicatorAppearingAnimationCurve,
  41. SeparatorBuilder? separatorBuilder,
  42. CustomSeparatorBuilder<T>? customSeparatorBuilder,
  43. bool active = true,
  44. double inactiveOpacity = 0.6,
  45. Curve inactiveOpacityCurve = Curves.easeInOut,
  46. Duration inactiveOpacityDuration = const Duration(milliseconds: 350),
  47. PositionListener<T>? positionListener,
  48. Clip clipBehavior = Clip.antiAlias,
})

Special version of AnimatedToggleSwitch.size.

All size values (indicatorSize, iconSize) are relative to the specified height. (So an indicatorSize.width of 1.0 means equality of height - 2*borderWidth and the width of the indicator)

Maximum one argument of iconBuilder, customIconBuilder and iconList must be provided.

Maximum one argument of styleBuilder, customStyleBuilder and styleList must be provided.

Implementation

AnimatedToggleSwitch.sizeByHeight({
  super.key,
  this.height = 50.0,
  required this.current,
  required this.values,
  this.animationDuration = const Duration(milliseconds: 500),
  this.animationCurve = Curves.easeInOutCirc,
  Size indicatorSize = const Size.square(1.0),
  SimpleIconBuilder<T>? iconBuilder,
  AnimatedIconBuilder<T>? customIconBuilder,
  List<Widget>? iconList,
  this.onChanged,
  this.borderWidth = 2.0,
  this.style = const ToggleStyle(),
  this.styleBuilder,
  this.customStyleBuilder,
  this.styleList,
  double selectedIconScale = sqrt2,
  this.iconAnimationCurve = Curves.easeOutBack,
  this.iconAnimationDuration,
  this.iconOpacity = 0.5,
  double spacing = 0.0,
  this.foregroundIndicatorIconBuilder,
  this.selectedIconOpacity = 1.0,
  this.iconAnimationType = AnimationType.onSelected,
  this.styleAnimationType = AnimationType.onSelected,
  this.indicatorAnimationType = AnimationType.onHover,
  this.onTap,
  this.fittingMode = FittingMode.preventHorizontalOverlapping,
  this.minTouchTargetSize = 48.0,
  this.textDirection,
  this.iconsTappable = true,
  this.cursors = const ToggleCursors(),
  this.loadingIconBuilder = _defaultLoadingIconBuilder,
  this.loading,
  this.loadingAnimationDuration,
  this.loadingAnimationCurve,
  this.allowUnlistedValues = false,
  this.indicatorAppearingBuilder = _defaultIndicatorAppearingBuilder,
  this.indicatorAppearingDuration =
      _defaultIndicatorAppearingAnimationDuration,
  this.indicatorAppearingCurve = _defaultIndicatorAppearingAnimationCurve,
  this.separatorBuilder,
  this.customSeparatorBuilder,
  this.active = true,
  this.inactiveOpacity = 0.6,
  this.inactiveOpacityCurve = Curves.easeInOut,
  this.inactiveOpacityDuration = const Duration(milliseconds: 350),
  this.positionListener,
  this.clipBehavior = Clip.antiAlias,
})  : indicatorSize = indicatorSize * (height - 2 * borderWidth),
      spacing = spacing * (height - 2 * borderWidth),
      animatedIconBuilder = _iconSizeBuilder<T>(
          iconBuilder, customIconBuilder, iconList, selectedIconScale),
      _iconArrangement = IconArrangement.row,
      super(
        values: values,
        styleBuilder: styleBuilder,
        customStyleBuilder: customStyleBuilder,
        styleList: styleList,
        iconList: iconList,
      );