AnimatedToggleSwitch<T extends Object?>.rollingByHeight constructor

AnimatedToggleSwitch<T extends Object?>.rollingByHeight({
  1. Key? key,
  2. double height = 50.0,
  3. required T current,
  4. required List<T> values,
  5. SimpleRollingIconBuilder<T>? iconBuilder,
  6. RollingIconBuilder<T>? customIconBuilder,
  7. List<Widget>? iconList,
  8. Duration animationDuration = const Duration(milliseconds: 500),
  9. Curve animationCurve = Curves.easeInOutCirc,
  10. Size indicatorSize = const Size.square(1.0),
  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 iconOpacity = 0.5,
  18. double spacing = 0.0,
  19. AnimationType styleAnimationType = AnimationType.onSelected,
  20. AnimationType indicatorAnimationType = AnimationType.onHover,
  21. TapCallback<T>? onTap,
  22. FittingMode fittingMode = FittingMode.preventHorizontalOverlapping,
  23. double minTouchTargetSize = 48.0,
  24. TextDirection? textDirection,
  25. bool iconsTappable = true,
  26. ToggleCursors cursors = const ToggleCursors(),
  27. LoadingIconBuilder<T> loadingIconBuilder = _defaultLoadingIconBuilder,
  28. bool? loading,
  29. Duration? loadingAnimationDuration,
  30. Curve? loadingAnimationCurve,
  31. ForegroundIndicatorTransition indicatorTransition = const ForegroundIndicatorTransition.rolling(),
  32. bool allowUnlistedValues = false,
  33. IndicatorAppearingBuilder indicatorAppearingBuilder = _defaultIndicatorAppearingBuilder,
  34. Duration indicatorAppearingDuration = _defaultIndicatorAppearingAnimationDuration,
  35. Curve indicatorAppearingCurve = _defaultIndicatorAppearingAnimationCurve,
  36. SeparatorBuilder? separatorBuilder,
  37. CustomSeparatorBuilder<T>? customSeparatorBuilder,
  38. bool active = true,
  39. double inactiveOpacity = 0.6,
  40. Curve inactiveOpacityCurve = Curves.easeInOut,
  41. Duration inactiveOpacityDuration = const Duration(milliseconds: 350),
  42. PositionListener<T>? positionListener,
  43. Clip clipBehavior = Clip.antiAlias,
  44. double indicatorIconScale = 1.0,
})

Special version of AnimatedToggleSwitch.rolling.

All size values (spacing, indicatorSize, selectedIconSize) 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)

indicatorIconScale defines the scale of the indicator icon. This is useful in combination with iconList if you want the icons in the foreground to be slightly bigger.

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

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

Implementation

AnimatedToggleSwitch.rollingByHeight({
  super.key,
  this.height = 50.0,
  required this.current,
  required this.values,
  SimpleRollingIconBuilder<T>? iconBuilder,
  RollingIconBuilder<T>? customIconBuilder,
  List<Widget>? iconList,
  this.animationDuration = const Duration(milliseconds: 500),
  this.animationCurve = Curves.easeInOutCirc,
  Size indicatorSize = const Size.square(1.0),
  this.onChanged,
  this.borderWidth = 2.0,
  this.style = const ToggleStyle(),
  this.styleBuilder,
  this.customStyleBuilder,
  this.styleList,
  this.iconOpacity = 0.5,
  double spacing = 0.0,
  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,
  ForegroundIndicatorTransition indicatorTransition =
      const ForegroundIndicatorTransition.rolling(),
  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,
  double indicatorIconScale = 1.0,
})  : iconAnimationCurve = Curves.linear,
      spacing = spacing * (height - 2 * borderWidth),
      iconAnimationDuration = Duration.zero,
      indicatorSize = indicatorSize * (height - 2 * borderWidth),
      selectedIconOpacity = iconOpacity,
      iconAnimationType = AnimationType.onSelected,
      foregroundIndicatorIconBuilder =
          _rollingForegroundIndicatorIconBuilder<T>(
              values,
              iconBuilder,
              customIconBuilder,
              iconList,
              height,
              borderWidth,
              indicatorTransition,
              indicatorIconScale),
      animatedIconBuilder = _standardIconBuilder(
          iconBuilder, customIconBuilder, iconList, height, borderWidth),
      _iconArrangement = IconArrangement.row,
      super(
        values: values,
        styleBuilder: styleBuilder,
        customStyleBuilder: customStyleBuilder,
        styleList: styleList,
        iconList: iconList,
      );