Contact.fromMap constructor

Contact.fromMap(
  1. dynamic dyn,
  2. ContactMode? mode
)

Implementation

factory Contact.fromMap(final dyn, ContactMode? mode) {
  mode ??= contactModeOf(dyn["mode"])!;
  return Contact(
    identifier: dyn[_kidentifier] as String?,
    displayName: dyn[_kdisplayName] as String?,
    givenName: dyn[_kgivenName] as String?,
    middleName: dyn[_kmiddleName] as String?,
    familyName: dyn[_kfamilyName] as String?,
    prefix: dyn[_kprefix] as String?,
    keys: ContactKeys.of(mode, dyn),
    lastModified: parseDateTime(dyn[_klastModified]),
    suffix: dyn[_ksuffix] as String?,
    company: dyn[_kcompany] as String?,
    jobTitle: dyn[_kjobTitle] as String?,
    linkedContactIds: <String>[
      for (final c in _iterableKey(dyn, _klinkedContactIds)) "$c",
    ],
    emails: [for (final m in _iterableKey(dyn, _kemails)) Item.fromMap(m)]
        .notNullList(),
    phones: [for (final m in _iterableKey(dyn, _kphones)) Item.fromMap(m)]
        .notNullList(),
    socialProfiles: [
      for (final m in _iterableKey(dyn, _ksocialProfiles)) Item.fromMap(m)
    ].whereType<Item>().toList(),
    urls: [for (final m in _iterableKey(dyn, _kurls)) Item.fromMap(m)]
        .notNullList(),
    dates: [
      for (final m in _iterableKey(dyn, _kdates)) ContactDate.fromMap(m)
    ].notNullList(),
    postalAddresses: [
      for (final m in _iterableKey(dyn, _kpostalAddresses))
        PostalAddress.fromMap(m)
    ].notNullList(),
    avatar: dyn[_kavatar] as Uint8List?,
    note: dyn[_knote] as String?,
  );
}