@@ -131,6 +131,11 @@ class AnimatedToggleSwitch<T extends Object?>
131131 /// Size of the indicator.
132132 final Size indicatorSize;
133133
134+ /// Padding of the switch around the indicator and the icons.
135+ ///
136+ /// Defaults to [EdgeInsets.all(borderWidth)] .
137+ final EdgeInsetsGeometry ? padding;
138+
134139 /// Callback for selecting a new value. The new [current] should be set here.
135140 final ChangeCallback <T >? onChanged;
136141
@@ -335,6 +340,7 @@ class AnimatedToggleSwitch<T extends Object?>
335340 this .inactiveOpacityDuration = const Duration (milliseconds: 350 ),
336341 this .positionListener,
337342 this .clipBehavior = Clip .antiAlias,
343+ this .padding,
338344 }) : _iconArrangement = IconArrangement .row,
339345 super (
340346 values: values,
@@ -399,6 +405,7 @@ class AnimatedToggleSwitch<T extends Object?>
399405 this .inactiveOpacityDuration = const Duration (milliseconds: 350 ),
400406 this .positionListener,
401407 this .clipBehavior = Clip .antiAlias,
408+ this .padding,
402409 }) : spacing = spacing * (height - 2 * borderWidth),
403410 indicatorSize = indicatorSize * (height - 2 * borderWidth),
404411 _iconArrangement = IconArrangement .row,
@@ -465,6 +472,7 @@ class AnimatedToggleSwitch<T extends Object?>
465472 this .inactiveOpacityDuration = const Duration (milliseconds: 350 ),
466473 this .positionListener,
467474 this .clipBehavior = Clip .antiAlias,
475+ this .padding,
468476 }) : animatedIconBuilder = _iconSizeBuilder <T >(
469477 iconBuilder, customIconBuilder, iconList, selectedIconScale),
470478 _iconArrangement = IconArrangement .row,
@@ -534,6 +542,7 @@ class AnimatedToggleSwitch<T extends Object?>
534542 this .inactiveOpacityDuration = const Duration (milliseconds: 350 ),
535543 this .positionListener,
536544 this .clipBehavior = Clip .antiAlias,
545+ this .padding,
537546 }) : indicatorSize = indicatorSize * (height - 2 * borderWidth),
538547 spacing = spacing * (height - 2 * borderWidth),
539548 animatedIconBuilder = _iconSizeBuilder <T >(
@@ -631,6 +640,7 @@ class AnimatedToggleSwitch<T extends Object?>
631640 this .positionListener,
632641 this .clipBehavior = Clip .antiAlias,
633642 double indicatorIconScale = 1.0 ,
643+ this .padding,
634644 }) : iconAnimationCurve = Curves .linear,
635645 iconAnimationDuration = Duration .zero,
636646 selectedIconOpacity = iconOpacity,
@@ -714,6 +724,7 @@ class AnimatedToggleSwitch<T extends Object?>
714724 this .positionListener,
715725 this .clipBehavior = Clip .antiAlias,
716726 double indicatorIconScale = 1.0 ,
727+ this .padding,
717728 }) : iconAnimationCurve = Curves .linear,
718729 spacing = spacing * (height - 2 * borderWidth),
719730 iconAnimationDuration = Duration .zero,
@@ -912,6 +923,7 @@ class AnimatedToggleSwitch<T extends Object?>
912923 this .inactiveOpacityDuration = const Duration (milliseconds: 350 ),
913924 this .positionListener,
914925 this .clipBehavior = Clip .antiAlias,
926+ this .padding,
915927 }) : assert (clipAnimation || opacityAnimation),
916928 iconOpacity = 1.0 ,
917929 selectedIconOpacity = 1.0 ,
@@ -1115,7 +1127,7 @@ class AnimatedToggleSwitch<T extends Object?>
11151127 _indicatorBuilder (context, properties, style),
11161128 iconBuilder: (context, local, global) => _animatedOpacityIcon (
11171129 _animatedSizeIcon (context, local, global), local.value == current),
1118- padding: EdgeInsets .all (borderWidth),
1130+ padding: padding ?? EdgeInsets .all (borderWidth),
11191131 active: active,
11201132 wrapperBuilder: (context, global, child) {
11211133 return AnimatedOpacity (
0 commit comments