calendarEventAnoymizer function Null safety

CalendarEvent calendarEventAnoymizer(
  1. CalendarEvent event
)

A CalendarEvent anonymizer function. Anonymizes:

  • title
  • description
  • names of all attendees

Implementation

CalendarEvent calendarEventAnoymizer(CalendarEvent event) {
  if (event.title != null)
    event.title = sha1.convert(utf8.encode(event.title!)).toString();
  if (event.description != null)
    event.description =
        sha1.convert(utf8.encode(event.description!)).toString();
  if (event.attendees != null)
    event.attendees = event.attendees!
        .map((name) => sha1.convert(utf8.encode(name!)).toString())
        .toList();

  return event;
}