@@ -1064,14 +1064,10 @@ class AnimatedToggleSwitch<T> extends _AnimatedToggleSwitchParent<T> {
10641064 padding: EdgeInsets .all (borderWidth),
10651065 active: active,
10661066 wrapperBuilder: (context, global, child) {
1067- return _ConditionalWrapper (
1068- condition: inactiveOpacity < 1.0 ,
1069- wrapper: (context, child) => AnimatedOpacity (
1070- opacity: global.active ? 1.0 : inactiveOpacity,
1071- duration: inactiveOpacityDuration,
1072- curve: inactiveOpacityCurve,
1073- child: child,
1074- ),
1067+ return AnimatedOpacity (
1068+ opacity: global.active ? 1.0 : inactiveOpacity,
1069+ duration: inactiveOpacityDuration,
1070+ curve: inactiveOpacityCurve,
10751071 child: _animationTypeBuilder <ToggleStyle >(
10761072 context,
10771073 styleAnimationType,
@@ -1110,7 +1106,6 @@ class AnimatedToggleSwitch<T> extends _AnimatedToggleSwitchParent<T> {
11101106 });
11111107 }
11121108
1113- //TODO: extract this method to separate widget
11141109 Widget _animationTypeBuilder <V >(
11151110 BuildContext context,
11161111 AnimationType animationType,
@@ -1119,7 +1114,6 @@ class AnimatedToggleSwitch<T> extends _AnimatedToggleSwitchParent<T> {
11191114 Widget Function (V value) builder,
11201115 GlobalToggleProperties <T > properties,
11211116 ) {
1122- double pos = properties.position;
11231117 switch (animationType) {
11241118 case AnimationType .onSelected:
11251119 V currentValue = valueProvider (
@@ -1133,23 +1127,15 @@ class AnimatedToggleSwitch<T> extends _AnimatedToggleSwitchParent<T> {
11331127 builder: (context, value, _) => builder (value),
11341128 );
11351129 case AnimationType .onHover:
1136- final index1 = pos.floor ();
1137- final index2 = pos.ceil ();
1138- final currentValue = properties.currentIndex < 0
1139- ? valueProvider (
1140- StyledToggleProperties (value: properties.current, index: - 1 ))
1141- : lerp (
1142- valueProvider (StyledToggleProperties (
1143- value: values[index1], index: index1)),
1144- valueProvider (StyledToggleProperties (
1145- value: values[index2], index: index2)),
1146- pos - pos.floor (),
1147- );
1148- return TweenAnimationBuilder <V >(
1149- duration: animationDuration,
1150- curve: animationCurve,
1151- tween: _CustomTween (lerp, begin: currentValue, end: currentValue),
1152- builder: (context, value, _) => builder (value),
1130+ return _AnimationTypeHoverBuilder (
1131+ valueProvider: valueProvider,
1132+ lerp: lerp,
1133+ builder: builder,
1134+ properties: properties,
1135+ animationDuration: animationDuration,
1136+ animationCurve: animationCurve,
1137+ indicatorAppearingDuration: indicatorAppearingDuration,
1138+ indicatorAppearingCurve: indicatorAppearingCurve,
11531139 );
11541140 }
11551141 }
@@ -1318,15 +1304,6 @@ class _MyLoading extends StatelessWidget {
13181304 }
13191305}
13201306
1321- class _CustomTween <V > extends Tween <V > {
1322- final V Function (V value1, V value2, double t) lerpFunction;
1323-
1324- _CustomTween (this .lerpFunction, {super .begin, super .end});
1325-
1326- @override
1327- V lerp (double t) => lerpFunction (begin as V , end as V , t);
1328- }
1329-
13301307extension _XTargetPlatform on TargetPlatform {
13311308 bool get isApple =>
13321309 this == TargetPlatform .iOS || this == TargetPlatform .macOS;
0 commit comments