MeCard.contact constructor

MeCard.contact({
  1. String? name,
  2. String? reading,
  3. String? tel,
  4. List<String>? tels,
  5. String? videophone,
  6. String? email,
  7. List<String>? emails,
  8. String? memo,
  9. DateTime? birthday,
  10. String? address,
  11. String? url,
  12. List<String>? urls,
  13. String? nickname,
})

Create a contact MeCard

Implementation

factory MeCard.contact({
  String? name,
  String? reading,
  String? tel,
  List<String>? tels,
  String? videophone,
  String? email,
  List<String>? emails,
  String? memo,
  DateTime? birthday,
  String? address,
  String? url,
  List<String>? urls,
  String? nickname,
}) {
  final fields = <MeTuple>[];

  if (name != null) {
    fields.add(MeTuple('N', name));
  }
  if (reading != null) {
    fields.add(MeTuple('SOUND', reading));
  }
  if (tel != null) {
    fields.add(MeTuple('TEL', tel));
  }
  if (tels != null) {
    for (final tel in tels) {
      fields.add(MeTuple('TEL', tel));
    }
  }
  if (videophone != null) {
    fields.add(MeTuple('TEL-AV', videophone));
  }
  if (email != null) {
    fields.add(MeTuple('EMAIL', email));
  }
  if (emails != null) {
    for (final email in emails) {
      fields.add(MeTuple('EMAIL', email));
    }
  }
  if (memo != null) {
    fields.add(MeTuple('NOTE', memo));
  }
  if (birthday != null) {
    fields.add(MeTuple.date('BDAY', birthday));
  }
  if (address != null) {
    fields.add(MeTuple('ADR', address));
  }
  if (url != null) {
    fields.add(MeTuple('URL', url));
  }
  if (urls != null) {
    for (final url in urls) {
      fields.add(MeTuple('URL', url));
    }
  }
  if (nickname != null) {
    fields.add(MeTuple('NICKNAME', nickname));
  }

  return MeCard(fields: fields);
}