Moved the building of the task list to a separate method
This commit is contained in:
parent
7b6b24a190
commit
f59f491022
1 changed files with 16 additions and 12 deletions
|
|
@ -54,18 +54,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||||
return Stack(
|
return Stack(
|
||||||
overflow: Overflow.visible,
|
overflow: Overflow.visible,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ListView(
|
buildTasksList(snap.data),
|
||||||
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(),
|
|
||||||
),
|
|
||||||
// This container is needed to make it seem like the search box is
|
// This container is needed to make it seem like the search box is
|
||||||
// part of the app bar.
|
// part of the app bar.
|
||||||
Container(
|
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() {
|
Widget buildSearchBox() {
|
||||||
return Row(
|
return Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue