Skip to content

Instantly share code, notes, and snippets.

@corelmax
Last active January 10, 2021 16:37
Show Gist options
  • Save corelmax/7032d2c446e33e8f148ccd2dee74275e to your computer and use it in GitHub Desktop.
Save corelmax/7032d2c446e33e8f148ccd2dee74275e to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:uuid/uuid.dart';
class TodoList extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return TodoListState();
}
}
class TodoListState extends State<TodoList> {
Widget _buildTodoList() {
return ListView.builder(
itemCount: todos.length,
itemBuilder: (context, index) {
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Checkbox(value: false, onChanged: (value) {
// we will update todo item here
}),
Expanded(
child: FocusScope(
onFocusChange: (bool focusing) {
if(!focusing) {
// we will update todo item here
}
},
child: TextField(
controller: TextEditingController(
text: 'todo text is here',
),
onChanged: (String text) {
// update todo's title here
},
)
)
),
IconButton(icon: Icon(Icons.delete), onPressed: () {
// delete todo item here
})
],
),
)
);
}
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Todo List'),
),
body: _buildTodoList(),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
// create todo item here
}
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment