Berikut adalah file template proyek aplikasi To-Do List sederhana menggunakan Flutter yang sudah dikemas dalam format ZIP:
file template proyek aplikasi To-Do List sederhana
📦 Unduh flutter_todo_app_template.zip
kamu mau versi APK siap install, versi Web App, atau ingin diubah menjadi aplikasi kasir / reminder / jualan online,
from zipfile import ZipFile
import os
# Folder structure and files for the Flutter To-Do app template
base_dir = '/mnt/data/todo_app/lib/models'
os.makedirs(base_dir, exist_ok=True)
# todo.dart file
todo_dart_content = """class Todo {
String title;
bool isDone;
Todo({
required this.title,
this.isDone = false,
});
void toggleDone() {
isDone = !isDone;
}
}
"""
# main.dart file
main_dart_content = """import 'package:flutter/material.dart';
import 'models/todo.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'To-Do List Sederhana',
home: TodoPage(),
);
}
}
class TodoPage extends StatefulWidget {
@override
_TodoPageState createState() => _TodoPageState();
}
class _TodoPageState extends State<TodoPage> {
final List<Todo> _todos = [];
final TextEditingController _controller = TextEditingController();
void _addTodo() {
if (_controller.text.isNotEmpty) {
setState(() {
_todos.add(Todo(title: _controller.text));
_controller.clear();
});
}
}
void _toggleDone(int index) {
setState(() {
_todos[index].toggleDone();
});
}
void _deleteTodo(int index) {
setState(() {
_todos.removeAt(index);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('To-Do List')),
body: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: TextField(
controller: _controller,
decoration: InputDecoration(labelText: 'Tugas baru'),
),
),
IconButton(
icon: Icon(Icons.add),
onPressed: _addTodo,
),
],
),
),
Expanded(
child: ListView.builder(
itemCount: _todos.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(
_todos[index].title,
style: TextStyle(
decoration: _todos[index].isDone
? TextDecoration.lineThrough
: null,
),
),
leading: Checkbox(
value: _todos[index].isDone,
onChanged: (_) => _toggleDone(index),
),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () => _deleteTodo(index),
),
);
},
),
),
],
),
);
}
}
"""
# Save the Dart files
with open('/mnt/data/todo_app/lib/models/todo.dart', 'w') as f:
f.write(todo_dart_content)
with open('/mnt/data/todo_app/lib/main.dart', 'w') as f:
f.write(main_dart_content)
# Create ZIP archive
zip_path = "/mnt/data/flutter_todo_app_template.zip"
with ZipFile(zip_path, 'w') as zipf:
for foldername, subfolders, filenames in os.walk('/mnt/data/todo_app'):
for filename in filenames:
file_path = os.path.join(foldername, filename)
zipf.write(file_path, os.path.relpath(file_path, '/mnt/data/todo_app'))
zip_path
Kamu bisa ekstrak file tersebut dan langsung melanjutkan pengembangan dengan Flutter di VS Code atau Android Studio. Kalau butuh bantuan untuk membuat versi APK atau ditambahkan fitur tertentu, tinggal beri tahu saja!

0 Komentar