VideoTextOverlay.fromJson constructor
VideoTextOverlay.fromJson(
- Map<String, dynamic> json
)
Implementation
factory VideoTextOverlay.fromJson(Map<String, dynamic> json) {
final endMs = json['endMs'] as int?;
return VideoTextOverlay(
id: json['id'] as String,
text: json['text'] as String? ?? '',
x: (json['x'] as num?)?.toDouble() ?? 0.5,
y: (json['y'] as num?)?.toDouble() ?? 0.5,
fontSize: (json['fontSize'] as num?)?.toDouble() ?? 64,
color: Color(json['color'] as int? ?? 0xFFFFFFFF),
startTime: Duration(milliseconds: json['startMs'] as int? ?? 0),
endTime: endMs == null ? null : Duration(milliseconds: endMs),
rotation: (json['rotation'] as num?)?.toDouble() ?? 0,
scale: (json['scale'] as num?)?.toDouble() ?? 1,
style: TextOverlayStyle.values.firstWhere(
(s) => s.name == json['style'],
orElse: () => TextOverlayStyle.outline,
),
backgroundColor: Color(json['backgroundColor'] as int? ?? 0xCC000000),
bold: json['bold'] as bool? ?? true,
stickerPath: json['stickerPath'] as String?,
);
}