curve static method
Returns a Color from the specified integer.
Returns black if it's not an integer; otherwise, passes it to the Color constructor.
This is useful in situations where null is not acceptable, for example,
when providing a decoder to list. Otherwise, prefer using DataSource.v
directly.
Returns a Curve from the specified string.
The given key should specify a string. If that string matches one of the
names of static curves defined in the Curves class, then that curve is
returned. Otherwise, if the string was not null, and is present as a key
in the curveDecoders map, then the matching decoder from that map is
invoked. Otherwise, the default obtained from AnimationDefaults.curveOf
is used (which is why a BuildContext is required).
Implementation
/// Returns a [Curve] from the specified string.
///
/// The given key should specify a string. If that string matches one of the
/// names of static curves defined in the [Curves] class, then that curve is
/// returned. Otherwise, if the string was not null, and is present as a key
/// in the [curveDecoders] map, then the matching decoder from that map is
/// invoked. Otherwise, the default obtained from [AnimationDefaults.curveOf]
/// is used (which is why a [BuildContext] is required).
static dynamic curve(Curve? curve) {
if (curve == null) return null;
switch (curve) {
case Curves.linear:
return 'linear';
case Curves.decelerate:
return 'decelerate';
case Curves.fastLinearToSlowEaseIn:
return 'fastLinearToSlowEaseIn';
case Curves.ease:
return 'ease';
case Curves.easeIn:
return 'easeIn';
case Curves.easeInToLinear:
return 'easeInToLinear';
case Curves.easeInSine:
return 'easeInSine';
case Curves.easeInQuad:
return 'easeInQuad';
case Curves.easeInCubic:
return 'easeInCubic';
case Curves.easeInQuart:
return 'easeInQuart';
case Curves.easeInQuint:
return 'easeInQuint';
case Curves.easeInExpo:
return 'easeInExpo';
case Curves.easeInCirc:
return 'easeInCirc';
case Curves.easeInBack:
return 'easeInBack';
case Curves.easeOut:
return 'easeOut';
case Curves.linearToEaseOut:
return 'linearToEaseOut';
case Curves.easeOutSine:
return 'easeOutSine';
case Curves.easeOutQuad:
return 'easeOutQuad';
case Curves.easeOutCubic:
return 'easeOutCubic';
case Curves.easeOutQuart:
return 'easeOutQuart';
case Curves.easeOutQuint:
return 'easeOutQuint';
case Curves.easeOutExpo:
return 'easeOutExpo';
case Curves.easeOutCirc:
return 'easeOutCirc';
case Curves.easeOutBack:
return 'easeOutBack';
case Curves.easeInOut:
return 'easeInOut';
case Curves.easeInOutSine:
return 'easeInOutSine';
case Curves.easeInOutQuad:
return 'easeInOutQuad';
case Curves.easeInOutCubic:
return 'easeInOutCubic';
case Curves.easeInOutCubicEmphasized:
return 'easeInOutCubicEmphasized';
case Curves.easeInOutQuart:
return 'easeInOutQuart';
case Curves.easeInOutQuint:
return 'easeInOutQuint';
case Curves.easeInOutExpo:
return 'easeInOutExpo';
case Curves.easeInOutCirc:
return 'easeInOutCirc';
case Curves.easeInOutBack:
return 'easeInOutBack';
case Curves.fastOutSlowIn:
return 'fastOutSlowIn';
case Curves.slowMiddle:
return 'slowMiddle';
case Curves.bounceIn:
return 'bounceIn';
case Curves.bounceOut:
return 'bounceOut';
case Curves.bounceInOut:
return 'bounceInOut';
case Curves.elasticIn:
return 'elasticIn';
case Curves.elasticOut:
return 'elasticOut';
case Curves.elasticInOut:
return 'elasticInOut';
default:
final encoder = curveEncoders[curve.runtimeType];
if (encoder != null) {
return encoder(curve);
}
return null;
}
}