{"id":34512498,"url":"https://github.com/majharul-islam181/sqflite_flutter","last_synced_at":"2026-06-06T14:31:43.129Z","repository":{"id":320836624,"uuid":"1083499160","full_name":"majharul-islam181/sqflite_flutter","owner":"majharul-islam181","description":"A beautiful and fully functional Notes application built with Flutter and SQLite for local data persistence. This app demonstrates complete CRUD (Create, Read, Update, Delete) operations with a modern dark-themed UI.","archived":false,"fork":false,"pushed_at":"2025-10-26T10:25:20.000Z","size":469,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-25T15:16:46.892Z","etag":null,"topics":["flutter","localstorage","sqflite","sqlite"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/majharul-islam181.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-26T06:26:02.000Z","updated_at":"2025-10-26T10:25:23.000Z","dependencies_parsed_at":"2025-10-26T08:29:58.696Z","dependency_job_id":"91962d2a-b84b-457d-99ef-c913f062f7b4","html_url":"https://github.com/majharul-islam181/sqflite_flutter","commit_stats":null,"previous_names":["majharul-islam181/sqflite_flutter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/majharul-islam181/sqflite_flutter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majharul-islam181%2Fsqflite_flutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majharul-islam181%2Fsqflite_flutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majharul-islam181%2Fsqflite_flutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majharul-islam181%2Fsqflite_flutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/majharul-islam181","download_url":"https://codeload.github.com/majharul-islam181/sqflite_flutter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majharul-islam181%2Fsqflite_flutter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33986901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-06T02:00:07.033Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flutter","localstorage","sqflite","sqlite"],"created_at":"2025-12-24T04:11:06.964Z","updated_at":"2026-06-06T14:31:43.108Z","avatar_url":"https://github.com/majharul-islam181.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flutter SQLite CRUD - Notes App\n\nA beautiful and fully functional Notes application built with Flutter and SQLite for local data persistence. This app demonstrates complete CRUD (Create, Read, Update, Delete) operations with a modern dark-themed UI.\n\n\n## Table of Contents\n\n- [Features](#features)\n- [Screenshots](#screenshots)\n- [Architecture](#architecture)\n- [Getting Started](#getting-started)\n- [Project Structure](#project-structure)\n- [Database Schema](#database-schema)\n- [Key Components](#key-components)\n- [Dependencies](#dependencies)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Code Examples](#code-examples)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- **Full CRUD Operations**: Create, Read, Update, and Delete notes\n- **Local Database**: SQLite database for persistent data storage\n- **Beautiful UI**: Modern dark theme with staggered grid layout\n- **Note Properties**:\n  - Title and Description\n  - Importance flag\n  - Number rating (0-5)\n  - Creation timestamp\n- **Interactive Cards**: Color-coded note cards with varying heights\n- **Form Validation**: Input validation for note creation/editing\n- **Responsive Design**: Portrait-only orientation with adaptive layouts\n\n\n## Screenshots\n\n| Home Screen | Add/Edit Note | Note Details |\n|------------|---------------|--------------|\n| ![Home](images/3.png) | ![Add Note](images/4.png) | ![Details](images/5.png) |\n\n## Architecture\n\nThis project follows a clean architecture pattern with clear separation of concerns:\n\n```\nlib/\n├── db/              # Database layer\n├── model/           # Data models\n├── page/            # UI screens\n└── widgets/         # Reusable UI components\n```\n\n### Architecture Diagram\n\n## Getting Started\n\n### Prerequisites\n\n- Flutter SDK (3.6.0 or higher)\n- Dart SDK\n- Android Studio / VS Code\n- Android/iOS Emulator or Physical Device\n\n### Dependencies\n\nThis project uses the following packages:\n\n```yaml\ndependencies:\n  flutter:\n    sdk: flutter\n  cupertino_icons: ^1.0.8\n  sqflite: ^2.4.1                         # SQLite database\n  intl: ^0.20.2                            # Internationalization \u0026 date formatting\n  flutter_staggered_grid_view: ^0.7.0     # Staggered grid layout\n```\n\n## Installation\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/yourusername/sqflite_crud_flutter.git\n   cd sqflite_crud_flutter\n   ```\n\n2. **Install dependencies**\n   ```bash\n   flutter pub get\n   ```\n\n3. **Run the app**\n   ```bash\n   flutter run\n   ```\n\n## Project Structure\n\n```\nsqflite_crud_flutter/\n│\n├── android/                    # Android-specific files\n├── ios/                        # iOS-specific files\n├── lib/\n│   ├── db/\n│   │   └── notes_database.dart        # Database operations \u0026 singleton\n│   ├── model/\n│   │   └── note.dart                  # Note model \u0026 fields\n│   ├── page/\n│   │   ├── notes_page.dart            # Home screen with notes grid\n│   │   ├── edit_note_page.dart        # Add/Edit note screen\n│   │   └── note_detail_page.dart      # Note details screen\n│   ├── widgets/\n│   │   ├── note_card_widget.dart      # Note card UI component\n│   │   └── note_form_widget.dart      # Note form UI component\n│   └── main.dart                      # App entry point\n│\n├── pubspec.yaml                # Project dependencies\n└── README.md                   # This file\n```\n\n## Database Schema\n\n### Table: `notes`\n\n| Column | Type | Constraints | Description |\n|--------|------|-------------|-------------|\n| `_id` | INTEGER | PRIMARY KEY AUTOINCREMENT | Unique identifier |\n| `isImportant` | BOOLEAN | NOT NULL | Importance flag |\n| `number` | INTEGER | NOT NULL | Rating (0-5) |\n| `title` | TEXT | NOT NULL | Note title |\n| `description` | TEXT | NOT NULL | Note content |\n| `time` | TEXT | NOT NULL | Creation timestamp (ISO 8601) |\n\n\n## Key Components\n\n### 1. Database Layer ([lib/db/notes_database.dart](lib/db/notes_database.dart))\n\nThe `NotesDatabase` class implements the Singleton pattern for database management:\n\n**Key Methods:**\n- `create(Note note)` - Insert a new note\n- `readNote(int id)` - Retrieve a single note by ID\n- `readAllNotes()` - Retrieve all notes ordered by time\n- `update(Note note)` - Update an existing note\n- `delete(int id)` - Delete a note by ID\n- `close()` - Close database connection\n\n**Database Initialization:**\n```dart\nstatic final NotesDatabase instance = NotesDatabase._init();\n```\n\n### 2. Data Model ([lib/model/note.dart](lib/model/note.dart))\n\nThe `Note` class with JSON serialization:\n\n**Properties:**\n- `id` - Unique identifier (nullable for new notes)\n- `isImportant` - Boolean flag\n- `number` - Integer rating (0-5)\n- `title` - Note title\n- `description` - Note content\n- `createdTime` - DateTime timestamp\n\n**Methods:**\n- `fromJson()` - Create Note from database map\n- `toJson()` - Convert Note to database map\n- `copy()` - Create a copy with optional field updates\n\n### 3. User Interface\n\n#### Notes Page ([lib/page/notes_page.dart](lib/page/notes_page.dart))\n\nHome screen displaying all notes in a staggered grid layout.\n\n**Features:**\n- Staggered grid view with 2 columns\n- Loading indicator during data fetch\n- Empty state message\n- Floating action button for adding notes\n- Navigation to note details on tap\n\n![Notes Page](images/8.png)\n\n#### Add/Edit Note Page ([lib/page/edit_note_page.dart](lib/page/edit_note_page.dart))\n\nForm for creating new notes or editing existing ones.\n\n**Features:**\n- Form validation\n- Importance toggle switch\n- Number slider (0-5 rating)\n- Title and description text fields\n- Save button with validation state\n\n\n\n#### Note Detail Page ([lib/page/note_detail_page.dart](lib/page/note_detail_page.dart))\n\nDetailed view of a single note.\n\n**Features:**\n- Display title, description, and creation date\n- Edit button (navigates to edit page)\n- Delete button (removes note and returns to home)\n\n\n\n### 4. Widgets\n\n#### Note Card Widget ([lib/widgets/note_card_widget.dart](lib/widgets/note_card_widget.dart))\n\nReusable card component for displaying notes in the grid.\n\n**Features:**\n- Color rotation from predefined palette\n- Variable heights for staggered effect\n- Displays title and creation date\n- Responsive sizing\n\n**Color Palette:**\n```dart\n[\n  Colors.amber.shade300,\n  Colors.lightGreen.shade300,\n  Colors.lightBlue.shade300,\n  Colors.orange.shade300,\n  Colors.pinkAccent.shade100,\n  Colors.tealAccent.shade100\n]\n```\n\n#### Note Form Widget ([lib/widgets/note_form_widget.dart](lib/widgets/note_form_widget.dart))\n\nReusable form component for note input.\n\n**Features:**\n- Importance switch\n- Number slider\n- Title text field (single line, bold, 24pt)\n- Description text field (5 lines, 18pt)\n- Input validation\n\n## Code Examples\n\n### Creating a Note\n\n```dart\nfinal note = Note(\n  title: 'My First Note',\n  isImportant: true,\n  number: 5,\n  description: 'This is a sample note',\n  createdTime: DateTime.now(),\n);\n\nawait NotesDatabase.instance.create(note);\n```\n\n### Reading All Notes\n\n```dart\nfinal notes = await NotesDatabase.instance.readAllNotes();\n```\n\n### Updating a Note\n\n```dart\nfinal updatedNote = note.copy(\n  title: 'Updated Title',\n  description: 'Updated description',\n);\n\nawait NotesDatabase.instance.update(updatedNote);\n```\n\n### Deleting a Note\n\n```dart\nawait NotesDatabase.instance.delete(noteId);\n```\n\n### Database Table Creation\n\n```dart\nawait db.execute('''\nCREATE TABLE $tableNotes(\n  ${NoteFields.id} INTEGER PRIMARY KEY AUTOINCREMENT,\n  ${NoteFields.isImportant} BOOLEAN NOT NULL,\n  ${NoteFields.number} INTEGER NOT NULL,\n  ${NoteFields.title} TEXT NOT NULL,\n  ${NoteFields.description} TEXT NOT NULL,\n  ${NoteFields.time} TEXT NOT NULL\n)\n''');\n```\n\n## Usage\n\n### Adding a Note\n\n1. Tap the floating action button (+) on the home screen\n2. Toggle importance switch if needed\n3. Adjust the rating slider (0-5)\n4. Enter a title and description\n5. Tap the \"Save\" button\n\n### Viewing Note Details\n\n1. Tap on any note card in the grid\n2. View the full title, description, and creation date\n\n### Editing a Note\n\n1. Open note details\n2. Tap the edit icon in the app bar\n3. Modify the fields as needed\n4. Tap \"Save\"\n\n### Deleting a Note\n\n1. Open note details\n2. Tap the delete icon in the app bar\n3. Note is immediately deleted\n\n## Theme Configuration\n\nThe app uses a dark theme with the following configuration:\n\n```dart\nThemeData(\n  primaryColor: Colors.black,\n  scaffoldBackgroundColor: Colors.blueGrey.shade900,\n  appBarTheme: AppBarTheme(\n    backgroundColor: Colors.transparent,\n    elevation: 0,\n  ),\n)\n```\n\n## Database Operations Flow\n\n```\nUser Action → UI Page → NotesDatabase → SQLite → Response\n     ↓\n   Update UI\n```\n\n1. User performs action (create, read, update, delete)\n2. UI page calls corresponding NotesDatabase method\n3. NotesDatabase executes SQLite query\n4. Result returned to UI page\n5. UI updates with new data\n\n## Performance Considerations\n\n- **Singleton Pattern**: Database instance is reused throughout the app\n- **Async Operations**: All database operations are asynchronous\n- **Lazy Loading**: Database is initialized only when first accessed\n- **Resource Management**: Database connection closed when app is disposed\n\n## Error Handling\n\nThe app includes error handling for:\n- Empty form validation\n- Missing note IDs\n- Database initialization failures\n- Navigation state management\n\n## Future Enhancements\n\nPotential features for future versions:\n\n- [ ] Search functionality\n- [ ] Note categories/tags\n- [ ] Color picker for custom note colors\n- [ ] Note sharing\n- [ ] Data export/import\n- [ ] Cloud synchronization\n- [ ] Rich text editing\n- [ ] Image attachments\n- [ ] Dark/Light theme toggle\n- [ ] Sorting and filtering options\n\n## Troubleshooting\n\n### Common Issues\n\n**Database not initializing:**\n```dart\n// Ensure WidgetsFlutterBinding is initialized\nWidgetsFlutterBinding.ensureInitialized();\n```\n\n**Portrait orientation not locked:**\n```dart\nawait SystemChrome.setPreferredOrientations([\n  DeviceOrientation.portraitUp,\n  DeviceOrientation.portraitDown,\n]);\n```\n\n## Contributing\n\nContributions are welcome! Please follow these steps:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Acknowledgments\n\n- Flutter team for the amazing framework\n- SQLite for reliable local storage\n- Community packages: sqflite, intl, flutter_staggered_grid_view\n\n## Contact\n\nFor questions or feedback, please open an issue on GitHub.\n\n---\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmajharul-islam181%2Fsqflite_flutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmajharul-islam181%2Fsqflite_flutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmajharul-islam181%2Fsqflite_flutter/lists"}