AnimatedToggleSwitch<T extends Object?>.dual constructor

AnimatedToggleSwitch<T extends Object?>.dual({
  1. Key? key,
  2. required T current,
  3. required T first,
  4. required T second,
  5. SimpleIconBuilder<T>? iconBuilder,
  6. IconBuilder<T>? customIconBuilder,
  7. SimpleIconBuilder<T>? textBuilder,
  8. AnimatedIconBuilder<T>? customTextBuilder,
  9. Duration animationDuration = const Duration(milliseconds: 500),
  10. Curve animationCurve = Curves.easeInOutCirc,
  11. Size indicatorSize = const Size.fromWidth(46.0),
  12. ChangeCallback<T>? onChanged,
  13. double borderWidth = 2.0,
  14. ToggleStyle style = const ToggleStyle(),
  15. StyleBuilder<T>? styleBuilder,
  16. CustomStyleBuilder<T>? customStyleBuilder,
  17. List<ToggleStyle>? styleList,
  18. double spacing = 40.0,
  19. double height = 50.0,
  20. Duration? iconAnimationDuration = const Duration(milliseconds: 500),
  21. Curve iconAnimationCurve = Curves.easeInOut,
  22. AnimationType styleAnimationType = AnimationType.onHover,
  23. AnimationType indicatorAnimationType = AnimationType.onHover,
  24. FittingMode fittingMode = FittingMode.preventHorizontalOverlapping,
  25. TapCallback<T>? onTap,
  26. double minTouchTargetSize = 48.0,
  27. TextDirection? textDirection,
  28. ToggleCursors cursors = const ToggleCursors(defaultCursor: SystemMouseCursors.click),
  29. EdgeInsetsGeometry textMargin = const EdgeInsets.symmetric(horizontal: 8.0),
  30. Offset animationOffset = const Offset(20.0, 0),
  31. bool clipAnimation = true,
  32. bool opacityAnimation = true,
  33. LoadingIconBuilder<T> loadingIconBuilder = _defaultLoadingIconBuilder,
  34. bool? loading,
  35. Duration? loadingAnimationDuration,
  36. Curve? loadingAnimationCurve,
  37. ForegroundIndicatorTransition indicatorTransition = const ForegroundIndicatorTransition.rolling(),
  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,
})

Defining an rolling animation using the foregroundIndicatorIconBuilder of AnimatedToggleSwitch.

Maximum one builder of iconBuilder and customIconBuilder must be provided.

Maximum one builder of textBuilder and customTextBuilder must be provided.

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

Implementation

AnimatedToggleSwitch.dual({
  super.key,
  required this.current,
  required T first,
  required T second,
  SimpleIconBuilder<T>? iconBuilder,
  IconBuilder<T>? customIconBuilder,
  SimpleIconBuilder<T>? textBuilder,
  AnimatedIconBuilder<T>? customTextBuilder,
  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.spacing = 40.0,
  this.height = 50.0,
  this.iconAnimationDuration = const Duration(milliseconds: 500),
  this.iconAnimationCurve = Curves.easeInOut,
  this.styleAnimationType = AnimationType.onHover,
  this.indicatorAnimationType = AnimationType.onHover,
  this.fittingMode = FittingMode.preventHorizontalOverlapping,
  TapCallback<T>? onTap,
  this.minTouchTargetSize = 48.0,
  this.textDirection,
  this.cursors = const ToggleCursors(defaultCursor: SystemMouseCursors.click),
  EdgeInsetsGeometry textMargin = const EdgeInsets.symmetric(horizontal: 8.0),
  Offset animationOffset = const Offset(20.0, 0),
  bool clipAnimation = true,
  bool opacityAnimation = true,
  this.loadingIconBuilder = _defaultLoadingIconBuilder,
  this.loading,
  this.loadingAnimationDuration,
  this.loadingAnimationCurve,
  ForegroundIndicatorTransition indicatorTransition =
      const ForegroundIndicatorTransition.rolling(),
  this.active = true,
  this.inactiveOpacity = 0.6,
  this.inactiveOpacityCurve = Curves.easeInOut,
  this.inactiveOpacityDuration = const Duration(milliseconds: 350),
  this.positionListener,
})  : assert(clipAnimation || opacityAnimation),
      iconOpacity = 1.0,
      selectedIconOpacity = 1.0,
      values = [first, second],
      iconAnimationType = AnimationType.onHover,
      iconsTappable = false,
      onTap = onTap ?? _dualOnTap(onChanged, [first, second], current),
      foregroundIndicatorIconBuilder = _rollingForegroundIndicatorIconBuilder(
          [first, second],
          iconBuilder == null ? null : (v, f) => iconBuilder(v),
          customIconBuilder,
          null,
          height,
          borderWidth,
          indicatorTransition,
          1.0),
      animatedIconBuilder = _dualIconBuilder(
        textBuilder,
        customTextBuilder,
        [first, second],
        textMargin,
        animationOffset,
        clipAnimation,
        opacityAnimation,
      ),
      _iconArrangement = IconArrangement.overlap,
      allowUnlistedValues = false,
      indicatorAppearingBuilder = _defaultIndicatorAppearingBuilder,
      indicatorAppearingDuration =
          _defaultIndicatorAppearingAnimationDuration,
      indicatorAppearingCurve = _defaultIndicatorAppearingAnimationCurve,
      separatorBuilder = null,
      customSeparatorBuilder = null,
      super(
        values: [first, second],
        styleBuilder: styleBuilder,
        customStyleBuilder: customStyleBuilder,
        styleList: styleList,
        iconList: null,
      );