fromJson static method

dynamic fromJson(
  1. String widgetType,
  2. Map<String, dynamic> json,
  3. DynamicAttributes parser,
  4. ActionMapper actionMapper,
)
override

fromJson method

Implementation

static fromJson(String widgetType, Map<String, dynamic> json,
    DynamicAttributes parser, ActionMapper actionMapper) {
  if (widgetType != GMNType.googleMaps) {
    throw Exception('Invalid widget type');
  }

  final attributes = <String, dynamic>{};
  if (json['properties'] != null) {
    for (final entry in (json['properties'] as Map<String, dynamic>)
        .entries
        .where((e) => e.value != null && e.key != 'key')) {
      attributes[entry.key] = parser.fromJson(
        entry.key,
        entry.value,
        actionMapper,
      );
    }
  }

  final rectProperties = RectProperties.fromJson(json['rect_properties']);

  return GoogleMapsOpenNode(
    id: json['id'],
    name: json['name'],
    description: json['description'],
    parentID: json['parent_id'],
    attributes: attributes,
    rectProperties: rectProperties,
    updatedAt: DateTime.parse(json['updated_at']),
    childOrder: json['child_order'] != null
        ? (json['child_order'] as num).toDouble()
        : null,
    pageID: json['page_id'],
    stabilID: json['stabil_id'],
    componentID: json['component_id'],
    isLocked: json['is_locked'],
  );
}