Flutter Todo List Example

Are you looking to build a simple yet functional to-do list application using Flutter? You've come to the right place. Flutter, Google's UI toolkit for building natively compiled applications for mobile, web, and desktop from a single codebase, is an excellent choice for creating cross-platform apps. In this guide, we'll walk you through creating a basic to-do list app, covering essential Flutter concepts along the way.

the flow map for flutterr roadmap
the flow map for flutterr roadmap

Before we dive in, ensure you have Flutter installed on your machine. If not, follow the official Flutter installation guide to set up your development environment. Now, let's get started with our to-do list example.

Flutter Project Ideas
Flutter Project Ideas

Setting Up the Project

First, create a new Flutter project. Open your terminal or command prompt, then run:

Todo
Todo

flutter create todo_list_app

Navigate into the newly created project directory:

Flutter: Building a Reorderable ListView
Flutter: Building a Reorderable ListView

cd todo_list_app

Project Structure

Let's organize our project structure. Create the following folders and files inside the lib folder:

Flutter Project Ideas For Beginners
Flutter Project Ideas For Beginners
  • models (for the to-do item model)
  • screens (for the main app screen)
  • widgets (for reusable widgets)

To-Do Item Model

In the models folder, create a new file named todo_item.dart. Define the ToDoItem class with properties like id, title, and isDone.

two screens showing the settings and options for different items in an app or website design
two screens showing the settings and options for different items in an app or website design

class ToDoItem { ... }

Building the User Interface

Flutter Container Styling Cookbook | Borders, Shadows, Gradients & Glassmorphism
Flutter Container Styling Cookbook | Borders, Shadows, Gradients & Glassmorphism
Flutter Basics
Flutter Basics
Simple Notepad
Simple Notepad
a babysith's daily routine is shown with the text, beginner baby steps day 20
a babysith's daily routine is shown with the text, beginner baby steps day 20
a list for baby steps day 17
a list for baby steps day 17
a poster with instructions for flying lessons
a poster with instructions for flying lessons
AyeshaAppDev - Overview
AyeshaAppDev - Overview
π‘Ύπ’†π’†π’Œ 6 β€” 𝑻𝒐-𝑫𝒐 𝑨𝒑𝒑 π’˜π’Šπ’•π’‰ π‘·π’“π’π’—π’Šπ’…π’†π’“ 𝑺𝒕𝒂𝒕𝒆 π‘΄π’‚π’π’‚π’ˆπ’†π’Žπ’†π’π’•
π‘Ύπ’†π’†π’Œ 6 β€” 𝑻𝒐-𝑫𝒐 𝑨𝒑𝒑 π’˜π’Šπ’•π’‰ π‘·π’“π’π’—π’Šπ’…π’†π’“ 𝑺𝒕𝒂𝒕𝒆 π‘΄π’‚π’π’‚π’ˆπ’†π’Žπ’†π’π’•
Printable Cute Aesthetic Daily To-Do List  | Minimalist Productivity Planner for Focus&Goals
Printable Cute Aesthetic Daily To-Do List | Minimalist Productivity Planner for Focus&Goals
15 Easy Ways To Simplify Your Life And Home In 30 Days | Fleurish Collective
15 Easy Ways To Simplify Your Life And Home In 30 Days | Fleurish Collective
Detailed declutter room list
Detailed declutter room list
Flutter Installation Full Guide
Flutter Installation Full Guide
Flutter Bottom Sheet tutorial
Flutter Bottom Sheet tutorial
To-Do List Mobile App App Ui, To Do Task List App, To Do List App Ui, Todo List App Interface, Visual System, User Flow, Todo App Design, Todo App, Study Better
To-Do List Mobile App App Ui, To Do Task List App, To Do List App Ui, Todo List App Interface, Visual System, User Flow, Todo App Design, Todo App, Study Better
πŸš€ Flutter – Build Beautiful Apps with One Codebase
πŸš€ Flutter – Build Beautiful Apps with One Codebase
Simple Flutter Patterns
Simple Flutter Patterns
Printable Cute Aesthetic Daily To-Do List  | Minimalist Productivity Planner for Focus&Goals
Printable Cute Aesthetic Daily To-Do List | Minimalist Productivity Planner for Focus&Goals
Self Love Habits for Positive Energy + Self Love Energy Boost Routine for Daily Positivity
Self Love Habits for Positive Energy + Self Love Energy Boost Routine for Daily Positivity
Flutter Development Services
Flutter Development Services

Now let's create the main app screen. In the screens folder, create a new file named home_screen.dart. This screen will display the list of to-do items and provide functionality to add new items.

Home Screen Widgets

Create a new folder named widgets inside the lib folder. Inside this folder, create two new files: todo_list.dart and add_task_bar.dart. These widgets will display the list of to-do items and the input bar for adding new tasks, respectively.

Adding Functionality

To make our app interactive, we'll use the StatefulWidget class to manage the app's state. In the home_screen.dart file, wrap the Scaffold widget with a StatefulWidget. Inside the State class, create a List to store the to-do items and implement methods to add, remove, and mark items as done.

class HomeScreen extends StatefulWidget { ... }

class _HomeScreenState extends State { ... }

Connecting Widgets and Logic

Connect the widgets created earlier with the logic implemented in the _HomeScreenState class. Pass the list of to-do items and the methods to update the list to the ToDoList widget. Also, pass the addTask method to the AddTaskBar widget to add new items when the user taps the '+' icon.

ToDoList(todoItems: _todoItems, ...),

AddTaskBar(addTask: addTask, ...),

Running the App

Finally, run the app using the following command in your terminal:

flutter run

You should now see your to-do list app running on an emulator or a physical device. You can add new tasks, mark them as done, and remove them from the list.

Creating a simple to-do list app using Flutter is an excellent starting point for learning Flutter development. As you progress, you can enhance this app by adding features like task categorization, reminders, and cloud synchronization. Happy coding!