Moved the building of the task list to a separate method

This commit is contained in:
Mariano Uvalle 2019-03-27 15:52:16 -06:00
parent 7b6b24a190
commit f59f491022

View file

@ -54,18 +54,7 @@ class _HomeScreenState extends State<HomeScreen> {
return Stack(
overflow: Overflow.visible,
children: <Widget>[
ListView(
padding: EdgeInsets.only(top: _searchBoxHeight + 15),
children: snap.data
.map((task) => Container(
child: TaskListTile(
task: task,
onDone: () => bloc.markTaskAsDone(task),
),
padding: EdgeInsets.only(bottom: 12),
))
.toList(),
),
buildTasksList(snap.data),
// This container is needed to make it seem like the search box is
// part of the app bar.
Container(
@ -81,6 +70,21 @@ class _HomeScreenState extends State<HomeScreen> {
);
}
Widget buildTasksList(List<TaskModel> tasks) {
return ListView(
padding: EdgeInsets.only(top: _searchBoxHeight + 15),
children: tasks
.map((task) => Container(
child: TaskListTile(
task: task,
onDone: () => bloc.markTaskAsDone(task),
),
padding: EdgeInsets.only(bottom: 12),
))
.toList(),
);
}
Widget buildSearchBox() {
return Row(
children: <Widget>[