interpolate function Value interpolation
Returns an interpolator between the two arbitrary values a and b.
The interpolator implementation is based on the type of the end value b,
using the following algorithm:
- If
bis a number, use interpolateNumber. - If
bis aColoror a string that can be converted to aColor, use interpolateRgb. - If
bis a DateTime, use interpolateDate. - If
bis a string, use interpolateString. - If
bis a TypedData, use interpolateNumberList. - If
bis a List, use interpolateList. - Otherwise, it uses the constant
b.
It's important to note that, unless the chosen interpolator allows
otherwise, a and b must be of the same type.
Implementation
Object? Function(num) interpolate(Object? a, Object? b) {
return (b is num
? interpolateNumber
: b is String
? interpolateColorOrString
: b is Color
? interpolateRgb
: b is DateTime
? interpolateDate
: b is List
? interpolateList
: b is Map
? interpolateMap
: _object)(a, b);
}