InfoObject.fromMap constructor

InfoObject.fromMap(
  1. Map map
)

Creates an InfoObject from a map.

Implementation

factory InfoObject.fromMap(Map map) {
  if (!map.containsKey('title') ||
      !map.containsKey('version') ||
      map['title'] == null ||
      map['version'] == null) {
    throw Exception(
      'InfoObject must contain title and version fields and they cannot be null. Found: $map',
    );
  }
  return InfoObject(
    title: map['title'],
    description: map['description'],
    termsOfService: map['termsOfService'],
    contact: map['contact'] != null
        ? ContactObject.fromMap(map['contact'])
        : null,
    license: map['license'] != null
        ? LicenseObject.fromMap(map['license'])
        : null,
    version: map['version'],
  );
}