A task list connects several useful concepts: an input controller, a collection of data, repeated widgets and user actions. Keep the first version in memory so you can focus on the flow.
The complete starting point
import 'package:flutter/material.dart';
void main() => runApp(const MaterialApp(home: TaskPage()));
class TaskPage extends StatefulWidget {
const TaskPage({super.key});
@override
State<TaskPage> createState() => _TaskPageState();
}
class _TaskPageState extends State<TaskPage> {
final input = TextEditingController();
final tasks = <String>[];
void add() {
final text = input.text.trim();
if (text.isEmpty) return;
setState(() => tasks.add(text));
input.clear();
}
@override
void dispose() { input.dispose(); super.dispose(); }
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Make a little progress')),
body: Padding(padding: const EdgeInsets.all(20), child: Column(children: [
Row(children: [Expanded(child: TextField(controller: input,
onSubmitted: (_) => add(),
decoration: const InputDecoration(labelText: 'One useful thing'))),
IconButton(tooltip: 'Add task', onPressed: add, icon: const Icon(Icons.add))]),
const SizedBox(height: 16),
Expanded(child: tasks.isEmpty
? const Center(child: Text('Start with one small task.'))
: ListView.builder(itemCount: tasks.length, itemBuilder: (context, i) =>
ListTile(title: Text(tasks[i]), trailing: IconButton(
tooltip: 'Remove task', icon: const Icon(Icons.close),
onPressed: () => setState(() => tasks.removeAt(i)))))),
])),
);
}Trace the data flow
The input controller owns the text being edited. Submitting a non-empty value adds a task to the list. The list drives ListView.builder, and removing an item triggers a new description of the visible rows.
Know the limits
Tasks disappear when the app restarts. Identical strings are allowed. A production version usually needs stable IDs, persistence and an explicit completion state.
Trace add, render and remove as one data flow
The input controller holds editing text. add trims and validates that input, then appends an accepted value to tasks. The list builder reads that collection. Removing a row changes the same collection, so the next build can describe the updated list.
The prototype uses strings and positions because it is intentionally small. Once tasks can be edited, reordered or persisted, give them stable IDs and a model. A row’s current index is not a durable identity.
Add form validation for richer input rules, then introduce a repository when persistence is part of the requirement. Keep one authoritative task collection instead of several widget-local copies.
Try it yourself
Replace the strings with a Task class containing an ID, label and completed flag. Add a checkbox, then derive the remaining count from the collection.