Learn/Mini Projects/Project: Todo App

Project: Todo App

Build a complete todo list application

15 min~6 min read+100 FX

You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.

Table of Contents

  1. 1. Main Screen
  2. 2. Suggested Architecture Split
  3. 3. This Lesson In Simple Words
  4. 4. Your level focus
  5. 5. One practical habit
  6. 6. Deep Understanding Guide
  7. 7. Why this lesson matters
  8. 8. Study flow for better retention
  9. 9. Quick Glossary
  10. 10. Architecture Lens

Having trouble? AI is here to help

Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.

Use the AI button at the bottom of the screen

Todo App Project

This project puts together everything you have learned so far into a real, usable application. You will build a fully functional todo list app that lets users add new tasks, mark them as complete, delete them with a swipe, and filter the list by status. Along the way you will practice working with models, Provider state management, ListView.builder, Dismissible widgets, dialogs, and local storage. By the end, you will have a complete app that you can actually use on your phone.

Features to build:

  • Add new todos with a dialog
  • Mark todos as complete with a checkbox
  • Swipe to delete todos
  • Filter by status (all, active, completed)
  • Persist data locally so todos survive app restarts
dart
1// Todo model
2class Todo {
3 final String id;
4 String title;
5 bool isCompleted;
6
7 Todo({
8 required this.id,
9 required this.title,
10 this.isCompleted = false,
11 });
12}
13
14// Todo provider
15class TodoProvider extends ChangeNotifier {
16 List<Todo> _todos = [];
17 String _filter = 'all'; // all, active, completed
18
19 List<Todo> get todos {
20 switch (_filter) {
21 case 'active':
22 return _todos.where((t) => !t.isCompleted).toList();
23 case 'completed':
24 return _todos.where((t) => t.isCompleted).toList();
25 default:
26 return _todos;
27 }
28 }
29
30 void addTodo(String title) {
31 _todos.add(Todo(
32 id: DateTime.now().toString(),
33 title: title,
34 ));
35 notifyListeners();
36 }
37
38 void toggleTodo(String id) {
39 final todo = _todos.firstWhere((t) => t.id == id);
40 todo.isCompleted = !todo.isCompleted;
41 notifyListeners();
42 }
43
44 void deleteTodo(String id) {
45 _todos.removeWhere((t) => t.id == id);
46 notifyListeners();
47 }
48
49 void setFilter(String filter) {
50 _filter = filter;
51 notifyListeners();
52 }
53}

Main Screen

The main screen is where the user sees all their todos. It uses a Consumer widget to listen to the TodoProvider, which means the list automatically updates whenever a todo is added, deleted, or toggled. The AppBar contains a popup menu for switching between filter modes, and a FloatingActionButton at the bottom opens a dialog for creating new todos.

dart
1class TodoScreen extends StatelessWidget {
2 @override
3 Widget build(BuildContext context) {
4 return Scaffold(
5 appBar: AppBar(
6 title: Text('My Todos'),
7 actions: [
8 PopupMenuButton<String>(
9 onSelected: (filter) {
10 context.read<TodoProvider>().setFilter(filter);
11 },
12 itemBuilder: (context) => [
13 PopupMenuItem(value: 'all', child: Text('All')),
14 PopupMenuItem(value: 'active', child: Text('Active')),
15 PopupMenuItem(value: 'completed', child: Text('Completed')),
16 ],
17 ),
18 ],
19 ),
20 body: Consumer<TodoProvider>(
21 builder: (context, provider, child) {
22 if (provider.todos.isEmpty) {
23 return Center(child: Text('No todos yet!'));
24 }
25 return ListView.builder(
26 itemCount: provider.todos.length,
27 itemBuilder: (context, index) {
28 final todo = provider.todos[index];
29 return TodoTile(todo: todo);
30 },
31 );
32 },
33 ),
34 floatingActionButton: FloatingActionButton(
35 onPressed: () => _showAddDialog(context),
36 child: Icon(Icons.add),
37 ),
38 );
39 }
40}

Suggested Architecture Split

Treat this app as a small production project, not a demo. Keep these responsibilities separate:

  • Todo model: fields, serialization, and validation rules
  • TodoProvider: business actions (add, toggle, delete, filter)
  • Storage layer: load and save todos (SharedPreferences, Hive, or SQLite)
  • UI layer: screens, list tiles, dialogs, and filter controls

This separation gives you safer refactoring. For example, if you switch from SharedPreferences to Hive later, you should only touch the storage layer while provider and UI stay mostly unchanged.

Todo Product Decisions

  • Trim input and block empty todo titles before adding an item.
  • Choose default sort order (newest first or oldest first) and keep it stable.
  • Define what happens when deleting in filtered mode so source data stays correct.
  • Persist selected filter (all, active, completed) across app restarts.
  • Show a confirmation or undo action for destructive deletes to reduce mistakes.

Todo App Release Checklist

  • Add, toggle, and delete todos repeatedly while changing filters to confirm no stale UI state.
  • Restart the app and verify todo data plus filter preference are restored correctly.
  • Stress test with 50+ todos and confirm list scrolling remains smooth.
  • Verify swipe-to-delete removes the intended item and never deletes the wrong row.
  • Check empty state, long text wrapping, and accessibility tap targets for all controls.

This Lesson In Simple Words

Build a complete todo list application. This lesson adds one more building block for creating stable and user-friendly Flutter apps.

Your level focus

Connect each concept to real app features you can build.

One practical habit

After reading, rewrite the concept in your own words and apply it in a tiny runnable sample.

Deep Understanding Guide

Why this lesson matters

Each lesson becomes useful when you connect concept, implementation, and real-user outcome together.

Study flow for better retention

  1. Map the lesson to one screen, one user action, and one expected output.
  2. Use a simple cycle: understand, implement, test, and explain.
  3. If you can choose between two approaches and explain why, you are improving.

Common Mistakes To Avoid

  • Moving forward without checking whether the current concept is truly clear.
  • Copying code exactly without experimenting with small changes.
  • Skipping edge cases and only testing happy-path behavior.
  • Assuming one pattern works for every scenario without trade-off analysis.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Build one tiny example from memory after finishing this lesson.
  • Write one paragraph about where this concept fits in a real app.
  • Create one failure scenario and verify your app handles it safely.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "What pattern does this todo app use for state management?".

Quick Glossary

  • widget: A reusable UI building block in Flutter.
  • state: Data that can change and update what the user sees.
  • build: The method that describes UI for the current state.
  • provider: A dependency and state sharing pattern in widget trees.
  • validation: Checks that confirm input is correct before processing.

Code Comprehension Drill

  • State the purpose of the code block in one line before reading details.
  • Mark inputs, state changes, and final output.
  • Change one small value and predict what should happen before running.
  • Run again and compare your prediction with actual behavior.

Architecture Lens

Connect this lesson to separation of concerns so your codebase stays maintainable as it grows.

As your app grows, keep UI, state, and data responsibilities separate so each part stays testable and easier to modify.

Lesson Completion Checklist

  • I can explain "Project: Todo App" in simple words without reading notes.
  • I can describe one real app situation where this concept is required.
  • I know at least one mistake to avoid: Moving forward without checking whether the current concept is truly clear.
  • I can modify one code sample and correctly predict the behavior change.
  • I can finish required exercises with understanding, not trial-and-error guesses.

Frequently Asked Questions

What pattern does this todo app use for state management?

The app uses ChangeNotifier with Provider for state management.

How do you implement swipe-to-delete in a todo app?

Dismissible wraps list items and provides swipe-to-dismiss functionality with onDismissed callback.

What widget is best for a todo checkbox?

CheckboxListTile combines a Checkbox with a ListTile, perfect for todo items with title and completion status.

How do you persist todo data locally?

SharedPreferences for simple key-value or sqflite/Hive for complex data persistence across app restarts.

Suggest Improvement

Something seems incorrect, unclear, or missing? Let us know.

About The Author

FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.

Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.

Sign in to continue with exercises and quiz for this lesson.

Sign In to Continue