ChartAnimationPreset.fromJson constructor

ChartAnimationPreset.fromJson(
  1. Map<String, dynamic>? json
)

Implementation

factory ChartAnimationPreset.fromJson(Map<String, dynamic>? json) {
  if (json == null) return grow;
  final typeStr = json['type']?.toString().toLowerCase() ?? 'grow';
  final type = switch (typeStr) {
    'fade' => ChartAnimationType.fade,
    'draw' => ChartAnimationType.draw,
    'sweep' => ChartAnimationType.sweep,
    'morph' => ChartAnimationType.morph,
    'none' => ChartAnimationType.none,
    _ => ChartAnimationType.grow,
  };
  final ms = (json['duration'] as int?) ?? 600;
  return ChartAnimationPreset(
    duration: Duration(milliseconds: ms),
    curve: Curves.easeOutCubic,
    type: type,
  );
}