AnimatedToggleSwitch<T extends Object?>.dual constructor
AnimatedToggleSwitch<T extends Object?>.dual ({
- Key? key,
- required T current,
- required T first,
- required T second,
- SimpleIconBuilder<
T> ? iconBuilder, - IconBuilder<
T> ? customIconBuilder, - SimpleIconBuilder<
T> ? textBuilder, - AnimatedIconBuilder<
T> ? customTextBuilder, - Duration animationDuration = const Duration(milliseconds: 500),
- Curve animationCurve = Curves.easeInOutCirc,
- Size indicatorSize = const Size.fromWidth(46.0),
- ChangeCallback<
T> ? onChanged, - double borderWidth = 2.0,
- ToggleStyle style = const ToggleStyle(),
- StyleBuilder<
T> ? styleBuilder, - CustomStyleBuilder<
T> ? customStyleBuilder, - List<
ToggleStyle> ? styleList, - double spacing = 40.0,
- double height = 50.0,
- Duration? iconAnimationDuration = const Duration(milliseconds: 500),
- Curve iconAnimationCurve = Curves.easeInOut,
- AnimationType styleAnimationType = AnimationType.onHover,
- AnimationType indicatorAnimationType = AnimationType.onHover,
- FittingMode fittingMode = FittingMode.preventHorizontalOverlapping,
- TapCallback<
T> ? onTap, - double minTouchTargetSize = 48.0,
- TextDirection? textDirection,
- ToggleCursors 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,
- LoadingIconBuilder<
T> loadingIconBuilder = _defaultLoadingIconBuilder, - bool? loading,
- Duration? loadingAnimationDuration,
- Curve? loadingAnimationCurve,
- ForegroundIndicatorTransition indicatorTransition = const ForegroundIndicatorTransition.rolling(),
- bool active = true,
- double inactiveOpacity = 0.6,
- Curve inactiveOpacityCurve = Curves.easeInOut,
- Duration inactiveOpacityDuration = const Duration(milliseconds: 350),
- PositionListener<
T> ? positionListener, - Clip clipBehavior = Clip.antiAlias,
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,
this.clipBehavior = Clip.antiAlias,
}) : 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,
);