NiceViewComponent.fromJson constructor

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

Implementation

factory NiceViewComponent.fromJson(Map<String, dynamic> json) {
  return NiceViewComponent(
    id: json['id'] as String,
    type: NiceViewComponentType.values.firstWhere(
      (t) => t.name == json['type'],
      orElse: () => NiceViewComponentType.text,
    ),
    title: json['title'] as String?,
    config: (json['config'] as Map<String, dynamic>?) ?? const {},
    children: (json['children'] as List?)
            ?.map((c) =>
                NiceViewComponent.fromJson(c as Map<String, dynamic>))
            .toList() ??
        const [],
    flex: json['flex'] as int? ?? 1,
  );
}