Skip to content

Latest commit

 

History

History

example

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Todo App

An example Flutter project, utilizing the treap package to handle version history.

You can add new tasks with the floating action button, mark them as completed by checking the tick mark, remove them by swiping, and edit on a separate page after tapping them.

On the main page, you can toggle whether to see competed tasks or not, and easily switch between version, using the undo, redo buttons, or the history slider.

The interesting bit is the way it uses treaps to maintain history, with full undo and redo, as well as animate between different list states.

I deliberately kept the dependencies of this app to a minimum, ie. it only depends on the treap package. In particular it lacks the state and dependency management of a real app (ie. bloc pattern or provider/riverpod), and rely on just setState.

Outline

Task

The stuff that needs done. Implemented as an immutable value object. Not much of interest here.

TodoList

Maintains two treaps (sets) of tasks; all and uncompleted. This is also immutable. Handles the transaction of updating both all and uncompleted, as tasks are added, updated (addOrUpdate), or removed (removed) .

History

Manage a historic stack of todo lists, with methods such as undo, redo, and change.

TaskListPage

Basically wraps an AnimatedList. The interesting bit is in the method _updateList that uses treap difference (set minus) to calculate what needs to be added/removed.