Facebook Twitter Instagram
    DeepCrazyWorld
    Facebook Twitter Instagram Pinterest YouTube
    • FLUTTER
      • FLUTTER APP
        • QRCode
        • Quiz App
        • Chat GPT
        • PDF App
        • News App
        • Fitness App
        • Weather App
        • BMI Calculator
        • GAME APP
        • Ecommerce App
        • wallpaper App
        • Finance app
        • Chat App
        • Wallet App
        • Taxi App
        • Quran app
        • Music player app
      • FLUTTER UI
        • Splash Screen
        • Onboarding Screen
        • Login Screen
        • Card Design
        • Drawer
    • PROJECT
      • Android Projects
      • College Projects
      • FLUTTER APP
      • Project Ideas
      • PHP Projects
      • Python Projects
    • SOURCE CODE
    • ANDROID
      • ANDROID APP
      • GAME APP
      • ANDROID STUDIO
    • MCQ
      • AKTU MCQ
        • RPA MCQ
        • COA MCQ
        • HPC MCQ
        • SPM MCQ
        • Renewable Energy All MCQ
        • Data Compression MCQ
        • Data Structure MCQ
        • Digital Image Processing MCQ
        • Software Engineering MCQ
        • Machine Learning MCQ
        • Artificial Intelligence MCQ
      • D PHARMA MCQ
        • Pharmaceutics – I MCQ
        • Pharmacognosy MCQ
        • Pharmaceutical Chemistry MCQ
        • Biochemistry and Clinical Pathology MCQ
        • Human Anatomy and Physiology MCQ
        • Heath Education and Community Pharmacy MCQ
    • INTERVIEW QUESTIONS
      • Flutter Interview Questions
      • INTERVIEW QUESTIONS
      • Python Interview Questions
      • Coding ninjas solution
    • MORE
      • WORDPRESS
        • SEO
        • TOP 10 WORDPRESS THEME
      • PRODUCTIVITY
      • Program
      • QUOTES
    DeepCrazyWorld
    Home»FLUTTER»How to Make a ToDo App with Flutter with source Code StepWise in 2024
    FLUTTER

    How to Make a ToDo App with Flutter with source Code StepWise in 2024

    DeepikaBy DeepikaAugust 17, 2024Updated:August 17, 2024No Comments4 Mins Read

    Creating a ToDo app with Flutter is a great way to get familiar with this powerful framework for building cross-platform mobile applications. Below, I’ll provide a step-by-step guide along with the source code for building a simple ToDo app in Flutter as of 2024.

    Table of Contents

    Toggle
    • Prerequisites:
    • Step 1: Create a New Flutter Project
    • Step 2: Set Up the Project Structure
    • Step 3: Define the ToDo Model
    • Step 4: Create the ToDo Item Widget
    • Step 5: Create the Home Screen
    • Step 6: Set Up the Main Entry Point
    • Step 7: Run the App
    • Step 8: Additional Improvements (Optional)
    • Complete Code
      • Related Articles:

    Prerequisites:

    • Flutter SDK installed
    • A code editor (e.g., Visual Studio Code or Android Studio)
    • Basic knowledge of Dart and Flutter

    Step 1: Create a New Flutter Project

    Open your terminal and create a new Flutter project by running:

    flutter create todo_app

    Navigate into the project directory:

    cd todo_app

    Step 2: Set Up the Project Structure

    Open the lib folder and create the following structure:

    lib/
    |-- main.dart
    |-- models/
    |   |-- todo.dart
    |-- screens/
    |   |-- home_screen.dart
    |-- widgets/
    |   |-- todo_item.dart

    Step 3: Define the ToDo Model

    Create a new file todo.dart under the models directory:

    // lib/models/todo.dart
    
    class ToDo {
      String title;
      bool isDone;
    
      ToDo({
        required this.title,
        this.isDone = false,
      });
    }

    Step 4: Create the ToDo Item Widget

    Create a new file todo_item.dart under the widgets directory:

    // lib/widgets/todo_item.dart
    
    import 'package:flutter/material.dart';
    import '../models/todo.dart';
    
    class ToDoItem extends StatelessWidget {
      final ToDo todo;
      final Function(bool?)? onChanged;
    
      ToDoItem({required this.todo, required this.onChanged});
    
      @override
      Widget build(BuildContext context) {
        return ListTile(
          leading: Checkbox(
            value: todo.isDone,
            onChanged: onChanged,
          ),
          title: Text(
            todo.title,
            style: TextStyle(
              decoration: todo.isDone ? TextDecoration.lineThrough : null,
            ),
          ),
        );
      }
    }

    Step 5: Create the Home Screen

    Create a new file home_screen.dart under the screens directory:

    // lib/screens/home_screen.dart
    
    import 'package:flutter/material.dart';
    import '../models/todo.dart';
    import '../widgets/todo_item.dart';
    
    class HomeScreen extends StatefulWidget {
      @override
      _HomeScreenState createState() => _HomeScreenState();
    }
    
    class _HomeScreenState extends State<HomeScreen> {
      final List<ToDo> _todoList = [];
      final TextEditingController _controller = TextEditingController();
    
      void _addTodo() {
        setState(() {
          _todoList.add(ToDo(
            title: _controller.text,
          ));
          _controller.clear();
        });
      }
    
      void _toggleTodoStatus(int index, bool? value) {
        setState(() {
          _todoList[index].isDone = value!;
        });
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('ToDo App'),
          ),
          body: Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: TextField(
                  controller: _controller,
                  decoration: InputDecoration(
                    labelText: 'Add a new task',
                    suffixIcon: IconButton(
                      icon: Icon(Icons.add),
                      onPressed: _addTodo,
                    ),
                  ),
                ),
              ),
              Expanded(
                child: ListView.builder(
                  itemCount: _todoList.length,
                  itemBuilder: (context, index) {
                    return ToDoItem(
                      todo: _todoList[index],
                      onChanged: (value) {
                        _toggleTodoStatus(index, value);
                      },
                    );
                  },
                ),
              ),
            ],
          ),
        );
      }
    }

    Step 6: Set Up the Main Entry Point

    Edit the main.dart file to set up the app’s entry point:

    // lib/main.dart
    
    import 'package:flutter/material.dart';
    import 'screens/home_screen.dart';
    
    void main() {
      runApp(ToDoApp());
    }
    
    class ToDoApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          home: HomeScreen(),
        );
      }
    }

    Step 7: Run the App

    Ensure your emulator or physical device is running, then start the app with:

    flutter run

    Step 8: Additional Improvements (Optional)

    1. Persistent Storage: You can use shared_preferences or a local database like SQLite to save tasks between app sessions.
    2. Task Editing: Add functionality to edit existing tasks.
    3. Categorization: Implement categories or labels for tasks.
    4. UI Enhancements: Improve the user interface with animations, themes, etc.

    Complete Code

    Here’s a zip of the complete project for your reference:

    todo_app.zip
    |
    |-- lib/
    |   |-- main.dart
    |   |-- models/
    |   |   |-- todo.dart
    |   |-- screens/
    |   |   |-- home_screen.dart
    |   |-- widgets/
    |       |-- todo_item.dart

    OUTPUT

    This basic ToDo app should give you a strong foundation for building more complex apps with Flutter. Feel free to customize and expand on this code to suit your needs!

    • Inheritance: A class can inherit properties and methods from another class. This is useful for creating more specialized versions of a class.
    • Mixins: Allow you to add functionality to a class from multiple sources.
    • Abstract Classes: Define methods without implementations that must be overridden by subclasses.

    Classes are a powerful way to structure your code in Flutter, helping you manage complex data and behaviors in a modular and reusable manner.

    Related Articles:

    • How to Install Flutter in windows 10
    • Quiz App using flutter with source code
    • Flutter NEWS App with REST APIs source code
    • Chat GPT Voice Chatbot App with Flutter source code
    • Make News and Weather App using flutter
    • A Book library App with Flutter source code
    • A Flutter MCQ quiz app with firebase google login
    • Message Chat App with Firebase using flutter
    • A Responsive flutter onboarding UI screen
    • Prepare your animated faq list easily with flutter
    • Flutter package multi_link_text allows you to create text
    • Make app more alive with beautiful animated Flutter icons
    • Daily News App built using Flutter framework
    • Login and Signup ui screen in flutter with source code

    Share. Facebook Twitter LinkedIn WhatsApp Telegram Pinterest Reddit Email
    Previous ArticleWhat is package in Flutter (Dart) with example in 2024
    Next Article How to make QR Scanner app in Flutter with Source Code Step by step

    Related Posts

    Implementing a Dynamic FAQ Screen UI in Flutter Using ExpansionTile

    FLUTTER 5 Mins Read

    Animated Backgrounds in Flutter: A Complete Guide

    FLUTTER 4 Mins Read

    How to make Diary App using flutter stepwise using getx

    FLUTTER APP 4 Mins Read

    How to Create Music Player UI screen with fully functional in flutter

    FLUTTER APP 3 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • Implementing a Dynamic FAQ Screen UI in Flutter Using ExpansionTile March 29, 2025
    • Creating an Instruction UI Screen in Flutter Application March 29, 2025
    • Animated Backgrounds in Flutter: A Complete Guide March 15, 2025
    • How to make Diary App using flutter stepwise using getx August 31, 2024
    • How to Create Music Player UI screen with fully functional in flutter August 30, 2024
    • How to make ListView Builder Ui in flutter with Source Code August 29, 2024
    • Create a TabBar View in flutter with fully functional stepwise August 28, 2024
    • How to create TabBar view in flutter with source code step wise August 27, 2024
    • How to make Heart rate measure app with Flutter stepwise August 26, 2024
    • How to make ChatGpt App in flutter with source code Stepwise August 25, 2024
    Facebook Twitter Instagram Pinterest YouTube
    • About
    • Contact
    • Disclaimer
    • Privacy Policy
    Copyright by DeepCrazyWorld © 2025

    Type above and press Enter to search. Press Esc to cancel.