todone_lib 0.1.1
todone_lib: ^0.1.1 copied to clipboard
A library made to parse and write tasks in the ToDone open format.
example/README.md
Accesing tasks #
You can access a particular task by iterating in any way the list.
The tasks object includes the following fields:
Status status: The status is taken from an enum that is eitherdoneorundoneDateTime? doneDateString priority: By default an empty StringDateTime? creationDateSet<String> tags: By default and empty SetDateTime? dueDateString title: By default an empty String
Creating a task #
The library includes a constructor that creates a Task object.
By default, when creating a Task object with only a title it's created with the undone status.
Task example1 = Task();
Task example2 = Task('This is a title');
Task example3 = Task('This is a title', Status.done);
Creating list of tasks #
Creating tasks from a file #
Either if you want to take care of the file handling you can call the parser with a File objecto or just the path you should just use the parser and it will return a List<Task>.
// You can use either var or List<Task> to use the parser
List<Task> tasksFromFile = ToDone().parseFromFile(File('path/to/file'));
List<Task> tasksFromPath = ToDone().parseFromPath('path/to/file');
Creating tasks from text #
If you already have text in a String you can pass the String to the parser.
Be aware that the parser separate lines using the \n symbol, so any other form of next line symbol won't work.
// You can use either var o List<Task> to use the parser
String text = '! This includes a task\n! This is a second task';
List<Task> tasksFromString = ToDone().parserFromString(text);
Writing list of tasks #
To write a List
ToDone().writeToFilePath('path/to/file', tasks);
ToDone().writeToFile(File('path/to/file'), tasks);