Skip to content

Commit a5d51df

Browse files
committed
65: adds padding to AnimatedToggleSwitch
1 parent 036a2f1 commit a5d51df

4 files changed

Lines changed: 91 additions & 75 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.8.5 (2025-04-28)
2+
3+
- adds `padding` to `AnimatedToggleSwitch` ([#65](https://github.com/splashbyte/animated_toggle_switch/issues/65))
4+
15
## 0.8.4 (2024-12-18)
26

37
- adds option to add `ToggleStyle` to `ThemeData` as `ThemeExtension`

example/pubspec.lock

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,50 @@ packages:
1212
dependency: transitive
1313
description:
1414
name: async
15-
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
15+
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
1616
url: "https://pub.dev"
1717
source: hosted
18-
version: "2.11.0"
18+
version: "2.12.0"
1919
boolean_selector:
2020
dependency: transitive
2121
description:
2222
name: boolean_selector
23-
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
23+
sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
2424
url: "https://pub.dev"
2525
source: hosted
26-
version: "2.1.1"
26+
version: "2.1.2"
2727
characters:
2828
dependency: transitive
2929
description:
3030
name: characters
31-
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
31+
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
3232
url: "https://pub.dev"
3333
source: hosted
34-
version: "1.3.0"
34+
version: "1.4.0"
3535
clock:
3636
dependency: transitive
3737
description:
3838
name: clock
39-
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
39+
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
4040
url: "https://pub.dev"
4141
source: hosted
42-
version: "1.1.1"
42+
version: "1.1.2"
4343
collection:
4444
dependency: transitive
4545
description:
4646
name: collection
47-
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
47+
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
4848
url: "https://pub.dev"
4949
source: hosted
50-
version: "1.19.0"
50+
version: "1.19.1"
5151
fake_async:
5252
dependency: transitive
5353
description:
5454
name: fake_async
55-
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
55+
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
5656
url: "https://pub.dev"
5757
source: hosted
58-
version: "1.3.1"
58+
version: "1.3.2"
5959
flutter:
6060
dependency: "direct main"
6161
description: flutter
@@ -75,18 +75,18 @@ packages:
7575
dependency: transitive
7676
description:
7777
name: leak_tracker
78-
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
78+
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
7979
url: "https://pub.dev"
8080
source: hosted
81-
version: "10.0.7"
81+
version: "10.0.8"
8282
leak_tracker_flutter_testing:
8383
dependency: transitive
8484
description:
8585
name: leak_tracker_flutter_testing
86-
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
86+
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
8787
url: "https://pub.dev"
8888
source: hosted
89-
version: "3.0.8"
89+
version: "3.0.9"
9090
leak_tracker_testing:
9191
dependency: transitive
9292
description:
@@ -99,10 +99,10 @@ packages:
9999
dependency: transitive
100100
description:
101101
name: matcher
102-
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
102+
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
103103
url: "https://pub.dev"
104104
source: hosted
105-
version: "0.12.16+1"
105+
version: "0.12.17"
106106
material_color_utilities:
107107
dependency: transitive
108108
description:
@@ -115,18 +115,18 @@ packages:
115115
dependency: transitive
116116
description:
117117
name: meta
118-
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
118+
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
119119
url: "https://pub.dev"
120120
source: hosted
121-
version: "1.15.0"
121+
version: "1.16.0"
122122
path:
123123
dependency: transitive
124124
description:
125125
name: path
126-
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
126+
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
127127
url: "https://pub.dev"
128128
source: hosted
129-
version: "1.9.0"
129+
version: "1.9.1"
130130
plugin_platform_interface:
131131
dependency: transitive
132132
description:
@@ -144,50 +144,50 @@ packages:
144144
dependency: transitive
145145
description:
146146
name: source_span
147-
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
147+
sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
148148
url: "https://pub.dev"
149149
source: hosted
150-
version: "1.10.0"
150+
version: "1.10.1"
151151
stack_trace:
152152
dependency: transitive
153153
description:
154154
name: stack_trace
155-
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
155+
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
156156
url: "https://pub.dev"
157157
source: hosted
158-
version: "1.12.0"
158+
version: "1.12.1"
159159
stream_channel:
160160
dependency: transitive
161161
description:
162162
name: stream_channel
163-
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
163+
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
164164
url: "https://pub.dev"
165165
source: hosted
166-
version: "2.1.2"
166+
version: "2.1.4"
167167
string_scanner:
168168
dependency: transitive
169169
description:
170170
name: string_scanner
171-
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
171+
sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
172172
url: "https://pub.dev"
173173
source: hosted
174-
version: "1.3.0"
174+
version: "1.4.1"
175175
term_glyph:
176176
dependency: transitive
177177
description:
178178
name: term_glyph
179-
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
179+
sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
180180
url: "https://pub.dev"
181181
source: hosted
182-
version: "1.2.1"
182+
version: "1.2.2"
183183
test_api:
184184
dependency: transitive
185185
description:
186186
name: test_api
187-
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
187+
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
188188
url: "https://pub.dev"
189189
source: hosted
190-
version: "0.7.3"
190+
version: "0.7.4"
191191
url_launcher:
192192
dependency: "direct main"
193193
description:
@@ -264,10 +264,10 @@ packages:
264264
dependency: transitive
265265
description:
266266
name: vm_service
267-
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
267+
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
268268
url: "https://pub.dev"
269269
source: hosted
270-
version: "14.3.0"
270+
version: "14.3.1"
271271
web:
272272
dependency: transitive
273273
description:
@@ -277,5 +277,5 @@ packages:
277277
source: hosted
278278
version: "1.0.0"
279279
sdks:
280-
dart: ">=3.4.0 <4.0.0"
280+
dart: ">=3.7.0-0 <4.0.0"
281281
flutter: ">=3.22.0"

lib/src/widgets/animated_toggle_switch.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)