Learn/Mini Projects/Project: Notes App

Project: Notes App

Build a notes app with local storage

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. Note Editor Screen
  2. 2. Data Lifecycle Design
  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

Notes App Project

This project combines local storage, CRUD operations, search functionality, and a polished editor experience into one app. You will build a notes application similar to Google Keep where users can create, read, edit, and delete notes. Each note has a title, content, timestamps, and an optional category. Notes are stored on the device using SharedPreferences so they persist across app restarts. This gives you hands-on practice with TextEditingController, navigation with data passing, JSON serialization, and filtering lists.

Features to build:

  • Create, read, update, and delete notes
  • Each note has title, content, timestamps, and optional category
  • Search notes by title or content
  • Display notes in a grid layout like Google Keep
  • Persist all data locally with SharedPreferences
dart
1// Note model
2class Note {
3 final String id;
4 String title;
5 String content;
6 DateTime createdAt;
7 DateTime updatedAt;
8 String? category;
9
10 Note({
11 required this.id,
12 required this.title,
13 required this.content,
14 required this.createdAt,
15 required this.updatedAt,
16 this.category,
17 });
18
19 Map<String, dynamic> toJson() => {
20 'id': id,
21 'title': title,
22 'content': content,
23 'createdAt': createdAt.toIso8601String(),
24 'updatedAt': updatedAt.toIso8601String(),
25 'category': category,
26 };
27
28 factory Note.fromJson(Map<String, dynamic> json) => Note(
29 id: json['id'],
30 title: json['title'],
31 content: json['content'],
32 createdAt: DateTime.parse(json['createdAt']),
33 updatedAt: DateTime.parse(json['updatedAt']),
34 category: json['category'],
35 );
36}
dart
1// Notes storage service
2class NotesStorage {
3 static const _key = 'notes';
4
5 Future<List<Note>> loadNotes() async {
6 final prefs = await SharedPreferences.getInstance();
7 final jsonString = prefs.getString(_key);
8 if (jsonString == null) return [];
9
10 final List jsonList = jsonDecode(jsonString);
11 return jsonList.map((json) => Note.fromJson(json)).toList();
12 }
13
14 Future<void> saveNotes(List<Note> notes) async {
15 final prefs = await SharedPreferences.getInstance();
16 final jsonString = jsonEncode(notes.map((n) => n.toJson()).toList());
17 await prefs.setString(_key, jsonString);
18 }
19}

Note Editor Screen

The editor screen handles both creating new notes and editing existing ones. It receives an optional existingNote parameter through its constructor. If a note is passed in, the text fields are pre-filled with the existing content. If not, the fields start empty for a new note. Two TextEditingControllers manage the title and content fields, and both are properly disposed when the screen is removed to prevent memory leaks.

dart
1class NoteEditorScreen extends StatefulWidget {
2 final Note? existingNote;
3
4 const NoteEditorScreen({this.existingNote});
5
6 @override
7 _NoteEditorScreenState createState() => _NoteEditorScreenState();
8}
9
10class _NoteEditorScreenState extends State<NoteEditorScreen> {
11 late TextEditingController _titleController;
12 late TextEditingController _contentController;
13
14 @override
15 void initState() {
16 super.initState();
17 _titleController = TextEditingController(
18 text: widget.existingNote?.title ?? '',
19 );
20 _contentController = TextEditingController(
21 text: widget.existingNote?.content ?? '',
22 );
23 }
24
25 @override
26 void dispose() {
27 _titleController.dispose();
28 _contentController.dispose();
29 super.dispose();
30 }
31
32 @override
33 Widget build(BuildContext context) {
34 return Scaffold(
35 appBar: AppBar(
36 title: Text(widget.existingNote == null ? 'New Note' : 'Edit Note'),
37 actions: [
38 IconButton(
39 icon: Icon(Icons.save),
40 onPressed: _saveNote,
41 ),
42 ],
43 ),
44 body: Padding(
45 padding: EdgeInsets.all(16),
46 child: Column(
47 children: [
48 TextField(
49 controller: _titleController,
50 decoration: InputDecoration(
51 hintText: 'Title',
52 border: InputBorder.none,
53 ),
54 style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
55 ),
56 Expanded(
57 child: TextField(
58 controller: _contentController,
59 decoration: InputDecoration(
60 hintText: 'Start writing...',
61 border: InputBorder.none,
62 ),
63 maxLines: null,
64 expands: true,
65 ),
66 ),
67 ],
68 ),
69 ),
70 );
71 }
72}

Data Lifecycle Design

Notes apps look simple, but data quality decides long-term usability. Define lifecycle rules now:

  • Generate stable unique IDs once and never mutate them.
  • Set createdAt only on creation, and update updatedAt on every edit.
  • Keep a predictable list ordering rule (for example, updatedAt descending).
  • Serialize with defensive defaults so older records still parse after schema changes.
  • Separate storage code from UI so you can later migrate from SharedPreferences to Hive or SQLite.

This mindset prevents subtle bugs like notes jumping order unexpectedly or old records crashing parsing.

Editing And Search Pitfalls

  • Forgetting to update updatedAt, which breaks recently edited sorting behavior.
  • Allowing save on a blank title and blank content, creating noisy unusable records.
  • Using case-sensitive search only, which misses obvious user matches.
  • Replacing the whole list incorrectly and losing one note during edit operations.
  • Skipping controller disposal in editor screens, causing memory leaks over time.

Notes App Quality Checklist

  • Create, edit, and delete flows all persist correctly after a full app restart.
  • Search results update instantly as query text changes.
  • Long note titles and bodies render without overflow in grid and editor views.
  • Canceling an edit does not overwrite existing saved content accidentally.
  • Timestamps display logically and remain correct after multiple edits.

This Lesson In Simple Words

Build a notes app with local storage. Backend integration connects app actions to real user data and secure business workflows.

Your level focus

Connect each concept to real app features you can build.

One practical habit

Define data model and access rules before writing convenience helper methods.

Deep Understanding Guide

Why this lesson matters

Security and data integrity issues can damage user trust faster than UI bugs.

Study flow for better retention

  1. Map the lesson to one screen, one user action, and one expected output.
  2. Think from both sides: client UX and backend authorization constraints.
  3. If you can choose between two approaches and explain why, you are improving.

Common Mistakes To Avoid

  • Trusting client-side checks without enforcing server-side rules.
  • Using broad read/write permissions in Firestore rules.
  • Storing secrets in plain text or unsafe local storage.
  • Not versioning schemas when documents evolve over time.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Write one secure Firestore rule and test allow/deny cases.
  • Map one backend document model to a typed client model.
  • Implement auth-state based screen routing with guarded actions.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "What package is commonly used for simple local storage in Flutter?".

Quick Glossary

  • build: The method that describes UI for the current state.
  • const: A compile-time constant that can reduce rebuild work.

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

Security rules are part of architecture, not optional deployment polish.

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: Notes 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: Trusting client-side checks without enforcing server-side rules.
  • 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 package is commonly used for simple local storage in Flutter?

SharedPreferences works for small amounts of key-value data. For production notes apps with many entries, consider sqflite or hive for better performance and querying.

What database is popular for local storage in Flutter notes apps?

sqflite provides SQLite and Hive provides NoSQL key-value storage, both run locally on the device.

What widget shows notes in a grid layout?

GridView displays items in a 2D grid (like Google Keep notes layout) using GridView.builder or GridView.count.

How do you implement a search feature for notes?

Use list.where() to filter notes whose title or content contains the search query string.

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