AnimatedToggleSwitch<T extends Object?>.rolling constructor

AnimatedToggleSwitch<T extends Object?>.rolling({
  1. Key? key,
  2. required T current,
  3. required List<T> values,
  4. SimpleRollingIconBuilder<T>? iconBuilder,
  5. RollingIconBuilder<T>? customIconBuilder,
  6. List<Widget>? iconList,
  7. Duration animationDuration = const Duration(milliseconds: 500),
  8. Curve animationCurve = Curves.easeInOutCirc,
  9. Size indicatorSize = const Size.fromWidth(46.0),
  10. ChangeCallback<T>? onChanged,
  11. double borderWidth = 2.0,
  12. ToggleStyle style = const ToggleStyle(),
  13. StyleBuilder<T>? styleBuilder,
  14. CustomStyleBuilder<T>? customStyleBuilder,
  15. List<ToggleStyle>? styleList,
  16. double iconOpacity = 0.5,
  17. double spacing = 0.0,
  18. double height = 50.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,
})

This constructor defines a rolling animation using the foregroundIndicatorIconBuilder of AnimatedToggleSwitch.

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.rolling({
  super.key,
  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,
  this.indicatorSize = const Size.fromWidth(46.0),
  this.onChanged,
  this.borderWidth = 2.0,
  this.style = const ToggleStyle(),
  this.styleBuilder,
  this.customStyleBuilder,
  this.styleList,
  this.iconOpacity = 0.5,
  this.spacing = 0.0,
  this.height = 50.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,
      iconAnimationDuration = Duration.zero,
      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,
      );