fromJson static method
Implementation
static Animation fromJson(Map<String, dynamic> json) {
final type = AnimationType.values.firstWhere(
(e) => e.toString().split('.').last == json['type'],
);
final start = json['start'] as int;
final end = json['end'] as int;
switch (type) {
case AnimationType.translate:
return TranslateAnimation(
start: start,
end: end,
x: json['x'] as int,
y: json['y'] as int,
);
case AnimationType.rotate:
return RotateAnimation(
start: start,
end: end,
angle: (json['angle'] as num).toDouble(),
pivotX: (json['pivotX'] as num).toDouble(),
pivotY: (json['pivotY'] as num).toDouble(),
);
case AnimationType.scale:
return ScaleAnimation(
start: start,
end: end,
scaleX: (json['scaleX'] as num).toDouble(),
scaleY: (json['scaleY'] as num).toDouble(),
pivotX: (json['pivotX'] as num).toDouble(),
pivotY: (json['pivotY'] as num).toDouble(),
);
case AnimationType.alpha:
return AlphaAnimation(
start: start,
end: end,
alpha: (json['alpha'] as num).toDouble(),
);
case AnimationType.sound:
return SoundAnimation(start: start, end: end);
}
}