Greetings, Flutter enthusiasts! Today, we embark on an exciting journey into Flutter development as we delve into creating a robust to-do app. Whether you're a seasoned developer or just starting with Flutter, this comprehensive guide will walk you through the process of building a feature-packed task manager.
In this tutorial, we'll cover everything from project setup to advanced features, providing you with a solid foundation in Flutter development. Follow each step, and by the end, you'll have a fully functional to-do app that showcases the power and flexibility of Flutter.
π Ready to get started? Let's dive into the world of Flutter development and craft an impressive to-do app together!
Feel free to customize the titles and descriptions based on your personal style and the specific det
Code:
import 'package:flutter/material.dart'; void main(){ runApp(TodoApp()); } class TodoApp extends StatelessWidget{ @override Widget build(BuildContext context){ return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Todo List App', home: TodoList(), ); } } class TodoList extends StatefulWidget { @override _TodoListState createState() => _TodoListState(); } class _TodoListState extends State<TodoList>{ List<String> tasks= []; TextEditingController taskController=TextEditingController(); @override Widget build(BuildContext context){ return Scaffold( appBar: AppBar( title: Text('Todo List'), ), body: Column( children: [ Padding( padding: const EdgeInsets.all(8.0), child: Row( children: [ Expanded( child: TextField( controller: taskController, decoration: InputDecoration( hintText: 'Enter The Task', ), ), ), IconButton( icon:Icon(Icons.add), onPressed:(){ addTask(); }, ), ], ), ), Expanded( child: ListView.builder( itemCount: tasks.length, itemBuilder: (context, index){ return ListTile( title: Text(tasks[index]), trailing: IconButton(icon: Icon(Icons.delete), onPressed: (){ deleteTask(index); }, ), ); }, ), ), ], ), ); } void addTask(){ String task = taskController.text.trim(); if(task.isNotEmpty){ setState((){ tasks.add(task); }); taskController.clear(); } } void deleteTask(int index){ setState((){ tasks.removeAt(index); }); } }
pubspec.yaml:
name: test1
description: "A new Flutter project."
publish_to: 'none'
version: 0.1.0
environment:
sdk: '>=3.2.2 <4.0.0'
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
Comments
Post a Comment