MotionConverter<T> class
abstract
A converter that handles normalization and denormalization of values for motion controllers.
This allows for different value types to be animated by converting them to and from lists of doubles that can be used by the animation system.
If your values have a defined order (e.g., double, int, etc.), consider using DirectionalMotionConverter instead to provide directionality information to motion controllers.
Motor owns the lists on both sides: don't keep or change the list normalize returns, or the one denormalize receives, after the call. Motor reuses its buffers, so a kept list would change under you. Build a new value from the numbers instead, as motor's own converters do.
Controllers and builders only swap to a converter that isn't equal to the
current one. Motor's converters compare by type, and
MotionConverter.custom ones by their functions, so pass top-level
functions or tear-offs rather than closures created in build. A
subclass that adds fields should override == and hashCode.
Constructors
- MotionConverter()
-
Creates a motion converter.
const
-
MotionConverter.custom({required Normalize<
T> normalize, required Denormalize<T> denormalize, List<MotionDimension> ? dimensions}) -
Creates a motion converter with normalize and denormalize functions.
constfactory
-
MotionConverter.customDirectional({required Normalize<
T> normalize, required Denormalize<T> denormalize, required int compare(T a, T b), List<MotionDimension> ? dimensions}) -
Creates a directional motion converter with normalize, denormalize and
compare functions.
constfactory
Properties
-
dimensions
→ List<
MotionDimension> ? -
How each normalized dimension behaves, or null when this converter
doesn't declare them (all linear, count unknown).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
denormalize(
List< double> values) → T -
Converts a list of double values back to a value of type
T. -
normalize(
T value) → List< double> -
Converts a value of type
Tto a list of double values. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- alignment → const AlignmentMotionConverter
- A motion converter for alignment values.
- angle → const AngleMotionConverter
- A motion converter for angles in radians, which take the short way round.
- colorRgb → const ColorRgbMotionConverter
- A motion converter for color values that interpolates in RGB space.
- edgeInsets → const EdgeInsetsMotionConverter
- A motion converter for EdgeInsets values.
- edgeInsetsDirectional → const EdgeInsetsDirectionalMotionConverter
- A motion converter for EdgeInsetsDirectional values.
- offset → const OffsetMotionConverter
- A motion converter for offset values.
- rect → const RectMotionConverter
- A motion converter for rect values.
- single → const SingleMotionConverter
- A motion converter for single values.
- size → const SizeMotionConverter
- A motion converter for size values.