PrismLottie.fromJson constructor

PrismLottie.fromJson(
  1. String json
)

Parses a Lottie JSON string.

Implementation

factory PrismLottie.fromJson(String json) {
  final decoded = jsonDecode(json) as Map<String, dynamic>;
  return PrismLottie(
    width: (decoded['w'] as num?)?.toDouble() ?? 0,
    height: (decoded['h'] as num?)?.toDouble() ?? 0,
    frameRate: (decoded['fr'] as num?)?.toDouble() ?? 30,
    frameCount: (decoded['op'] as num?)?.toInt() ?? 0,
    loop: decoded['loop'] as bool? ?? false,
    layers: (decoded['layers'] as List?)?.length ?? 0,
    version: decoded['v'] as String? ?? '',
  );
}