ICalendar.fromLines constructor

ICalendar.fromLines(
  1. List<String> lines, {
  2. bool allowEmptyLine = true,
})

Parse an ICalendar object from a List<String>.

The first line must be BEGIN:CALENDAR, and the last line must be END:CALENDAR.

The body MUST include the "PRODID" and "VERSION" calendar properties.

Implementation

factory ICalendar.fromLines(
  List<String> lines, {
  bool allowEmptyLine = true,
}) {
  if (allowEmptyLine) {
    while (lines.last.isEmpty) {
      lines.removeLast();
    }
  }
  final parsedData = fromListToJson(lines, allowEmptyLine: allowEmptyLine);
  return ICalendar(
    headData: parsedData.first as Map<String, dynamic>,
    data: parsedData.last as List<Map<String, dynamic>>,
  );
}