Skip to content

chavdapsr/to-do-list.github.io

Repository files navigation

To-Do List App

A full-stack to-do list application built with Flutter (frontend) and PHP (backend) with MySQL database.

Features

  • ✅ Add new tasks with title and optional description
  • ✅ Mark tasks as completed/incomplete
  • ✅ Edit existing tasks
  • ✅ Delete tasks with confirmation
  • ✅ Swipe to delete functionality
  • ✅ Beautiful and modern UI
  • ✅ Real-time updates
  • ✅ Error handling and loading states
  • ✅ Responsive design

Project Structure

to-do list/
├── backend/
│   └── api/
│       ├── config.php
│       ├── get_tasks.php
│       ├── add_task.php
│       ├── update_task.php
│       ├── update_task_content.php
│       └── delete_task.php
├── frontend/
│   ├── lib/
│   │   ├── main.dart
│   │   ├── models/
│   │   │   └── task.dart
│   │   ├── providers/
│   │   │   └── task_provider.dart
│   │   ├── screens/
│   │   │   └── main_screen.dart
│   │   ├── services/
│   │   │   └── api_service.dart
│   │   └── widgets/
│   │       ├── task_list.dart
│   │       ├── add_task_dialog.dart
│   │       └── edit_task_dialog.dart
│   └── pubspec.yaml
├── db.sql
└── README.md

Setup Instructions

Prerequisites

  1. Flutter SDK (latest stable version)
  2. PHP (7.4 or higher)
  3. MySQL (5.7 or higher)
  4. Web Server (Apache/Nginx) or Laragon/XAMPP

Backend Setup

  1. Database Setup:

    -- Run the SQL commands in db.sql
    CREATE DATABASE todo_db;
    USE todo_db;
    
    CREATE TABLE tasks (
        id INT AUTO_INCREMENT PRIMARY KEY,
        title VARCHAR(255) NOT NULL,
        description TEXT,
        completed BOOLEAN DEFAULT FALSE,
        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );
  2. Configure Database Connection:

    • Edit backend/api/config.php
    • Update database credentials:
      $host = 'localhost';
      $dbname = 'todo_db';
      $user = 'your_username';
      $password = 'your_password';
  3. Web Server Setup:

    • Place the backend folder in your web server's document root
    • Ensure PHP has PDO and MySQL extensions enabled
    • Test API endpoints:
      • http://localhost/backend/api/get_tasks.php

Frontend Setup

  1. Install Dependencies:

    cd frontend
    flutter pub get
  2. Configure API Base URL:

    • Edit frontend/lib/services/api_service.dart
    • Update the baseUrl to match your server:
      static const String baseUrl = 'http://localhost/backend/api/';
  3. Run the App:

    flutter run

API Endpoints

Method Endpoint Description
GET /get_tasks.php Fetch all tasks
POST /add_task.php Add new task
GET /update_task.php?id=X&completed=Y Toggle task completion
POST /update_task_content.php Update task title/description
GET /delete_task.php?id=X Delete task

Usage

  1. Adding Tasks:

    • Tap the + button
    • Enter task title (required)
    • Add description (optional)
    • Tap "Add Task"
  2. Completing Tasks:

    • Tap the checkbox next to any task
    • Task will be marked as completed with strikethrough
  3. Editing Tasks:

    • Tap the edit icon (pencil) next to any task
    • Modify title and/or description
    • Tap "Save"
  4. Deleting Tasks:

    • Tap the delete icon (trash) next to any task
    • Confirm deletion in the dialog
    • Or swipe left on any task to delete

Troubleshooting

Common Issues

  1. Database Connection Error:

    • Verify database credentials in config.php
    • Ensure MySQL service is running
    • Check if database todo_db exists
  2. API Connection Error:

    • Verify the baseUrl in api_service.dart
    • Ensure web server is running
    • Check if PHP files are accessible via browser
  3. CORS Issues:

    • All API endpoints include CORS headers
    • If issues persist, check web server configuration
  4. Flutter Build Issues:

    • Run flutter clean then flutter pub get
    • Ensure Flutter SDK is up to date

Development Tips

  • Use browser developer tools to test API endpoints
  • Check Flutter console for detailed error messages
  • Enable debug mode for more verbose logging

Technologies Used

  • Frontend: Flutter, Provider (state management)
  • Backend: PHP, MySQL, PDO
  • Architecture: RESTful API, MVC pattern

License

This project is open source and available under the MIT License.

About

to-do-list app front end flutter and backend php

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published