icalendar_parser 0.6.0 icalendar_parser: ^0.6.0 copied to clipboard
Package to parse iCalendar (.ics) files written in pure Dart.
icalendar_parser #
Package to parse iCalendar (.ics) files written in pure Dart.
Implementation of AnyFetch's ics-parser in JavaScript.
Getting Started #
Add icalendar_parser
to your pubspec.yaml:
icalendar_parser: any
How to use #
You can refer to the example/
folder for a complete example implemented in Flutter.
Constructor #
ICalendar.fromString #
Warning: For unknown reason the command dart test
on GitHub Actions will generate errors so try to prefer using ICalendar.fromLines
in your unit tests.
import 'package:flutter/services.dart' show rootBundle;
import 'package:icalendar_parser/icalendar_parser.dart';
final icsString = await rootBundle.loadString('assets/your_file.ics');
final iCalendar = ICalendar.fromString(icsString);
ICalendar.fromLines #
final icsLines = await File('your_file.ics').readAsLines();
final iCalendar = ICalendar.fromLines(lines);
Other methods #
ICalendar.registerField #
With this method you can add custom fields to the parsing and you can specify a custom function
to parse its content :
ICalendar.registerField(field: 'TEST');
ICalendar.registerField(
field: 'TEST2',
function: (value, params, event, lastEvent) {
lastEvent['test2'] = 'test';
return lastEvent;
},
);
ICalendar.unregisterField #
With this method you can remove parsed fields to ignore them in your file :
ICalendar.unregisterField('TEST');
Supported Properties #
- VERSION
- PRODID
- CALSCALE
- METHOD
- COMPONENT:BEGIN
- COMPONENT:END
- DTSTART
- DTEND
- DTSTAMP
- TRIGGER
- LAST-MODIFIED
- COMPLETED
- DUE
- UID
- SUMMARY
- DESCRIPTION
- LOCATION
- URL
- ORGANIZER
- GEO
- CATEGORIES
- ATTENDEE
- ACTION
- STATUS
- SEQUENCE
- REPEAT
- REPEAT