Skip to content

KaloyankerR/note_taking_app

Repository files navigation

Sure! Here is the complete README file in Markdown syntax:

Flutter Note-Taking App

Description

This is a simple and intuitive note-taking app built with Flutter. It allows you to create, update, delete, and view notes. The app also features a settings page where you can toggle between dark and light modes. The notes are stored locally using the Isar database.

Features

  • Home Page: View all your notes in one place.
  • Add Note: Click the add button to open a pop-up window where you can add a new note.
  • Update Note: Update existing notes.
  • Delete Note: Delete notes that you no longer need.
  • Settings Page: Switch between dark and light modes.
  • Local Storage: Notes are stored locally using the Isar database.

Screenshots

Home Page (Light Mode) Drawer (Light Mode)
Home Page Drawer
Settings Page (Dark Mode) Note Tile (Dark Mode)
Settings Page Note Tile
Update Note (Dark Mode) Create Note (Dark Mode)
Update Note Create Note

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/your-repo-name.git
    cd your-repo-name
  2. Install dependencies:

    flutter pub get
  3. Run the app:

    flutter run

Usage

Home Page

  • View Notes: On the home page, you can see all the notes you have created.
  • Add Note: Click the add button (typically a floating action button) to open a pop-up window where you can enter the text for your new note.

Add Note

  • Enter the text for your new note in the pop-up window and click the save button to add it to your list of notes.

Update and Delete Notes

  • Update: Click on an existing note to edit its text.
  • Delete: Swipe left on a note or click the delete button to remove it.

Settings Page

  • Toggle Mode: Open the settings page from the navigation drawer or a settings icon. Here, you can switch between dark mode and light mode.

Database

The app uses the Isar database to store notes locally. Isar is a high-performance database designed for Flutter and Dart.

Initialize Database

To initialize the Isar database, ensure you have the following setup in your code:

import 'package:isar/isar.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:developer';
import 'dart:io';

class NoteDatabase extends ChangeNotifier {
  static late Isar isar;

  static Future<void> clearDatabase() async {
    final dir = await getApplicationDocumentsDirectory();
    final dbDir = Directory(dir.path);
    if (await dbDir.exists()) {
      dbDir.deleteSync(recursive: true);
    }
  }

  static Future<void> initialize() async {
    try {
      await clearDatabase();
      final dir = await getApplicationDocumentsDirectory();
      log('Database directory: ${dir.path}');
      isar = await Isar.open([NoteSchema], directory: dir.path);
      log('Database initialized successfully');
    } catch (e) {
      log('Error initializing database: $e');
      rethrow;
    }
  }
}

Schema Definition

Ensure your schema is defined correctly:

import 'package:isar/isar.dart';

// Generates the file
// Run dart run build_runner build
part 'note.g.dart';

@Collection()
class Note {
  Id id = Isar.autoIncrement;
  late String text;
}