@@ -77,18 +77,7 @@ class _TaskListState extends State<TaskList> {
77
77
TextStyle (color: Colors .blue[900 ], fontWeight: FontWeight .bold),
78
78
),
79
79
subtitle: task["Time" ] != null ? Text (task["Time" ]) : null ,
80
- trailing: widget.isfinished
81
- ? IconButton (
82
- icon: Icon (Icons .delete),
83
- onPressed: () async {
84
- await confirmDialog (task).then ((value) {
85
- if (value)
86
- setState (() {
87
- database.deleteTask (task["ID" ]);
88
- });
89
- });
90
- })
91
- : Icon (Icons .delete),
80
+ trailing: Icon (Icons .delete),
92
81
),
93
82
);
94
83
}
@@ -97,56 +86,55 @@ class _TaskListState extends State<TaskList> {
97
86
return tasks.length != 0
98
87
? ListView .separated (
99
88
itemBuilder: (_, index) {
100
- return widget.isfinished
101
- ? listItem (tasks[index])
102
- : Dismissible (
103
- confirmDismiss: (direction) async {
104
- if (direction == DismissDirection .endToStart) {
105
- final bool res = await confirmDialog (tasks[index]);
106
- return res;
107
- } else {
108
- Fluttertoast .showToast (
109
- msg: "Task Finished" ,
110
- toastLength: Toast .LENGTH_SHORT ,
111
- gravity: ToastGravity .BOTTOM ,
112
- timeInSecForIosWeb: 1 ,
113
- backgroundColor: Colors .green,
114
- textColor: Colors .white,
115
- fontSize: 16.0 );
116
- return await database
117
- .addTask (tasks[index], isDone: true )
118
- .then ((value) => value);
119
- }
120
- },
121
- secondaryBackground: Card (
122
- shape: RoundedRectangleBorder (
123
- borderRadius: BorderRadius .circular (20.0 )),
124
- child: Center (
125
- child: Text (
126
- 'Delete' ,
127
- style: TextStyle (
128
- color: Colors .white,
129
- fontWeight: FontWeight .bold),
130
- ),
131
- ),
132
- color: Colors .red,
133
- ),
134
- background: Card (
135
- shape: RoundedRectangleBorder (
136
- borderRadius: BorderRadius .circular (20.0 )),
137
- child: Center (
138
- child: Text (
139
- 'Move To Finished' ,
140
- style: TextStyle (
141
- color: Colors .white,
142
- fontWeight: FontWeight .bold),
143
- ),
144
- ),
145
- color: Colors .green,
146
- ),
147
- child: listItem (tasks[index]),
148
- key: UniqueKey (),
149
- );
89
+ return Dismissible (
90
+ direction: widget.isfinished
91
+ ? DismissDirection .endToStart
92
+ : DismissDirection .horizontal,
93
+ confirmDismiss: (direction) async {
94
+ if (direction == DismissDirection .endToStart) {
95
+ final bool res = await confirmDialog (tasks[index]);
96
+ return res;
97
+ } else {
98
+ Fluttertoast .showToast (
99
+ msg: "Task Finished" ,
100
+ toastLength: Toast .LENGTH_SHORT ,
101
+ gravity: ToastGravity .BOTTOM ,
102
+ timeInSecForIosWeb: 1 ,
103
+ backgroundColor: Colors .green,
104
+ textColor: Colors .white,
105
+ fontSize: 16.0 );
106
+ return await database
107
+ .addTask (tasks[index], isDone: true )
108
+ .then ((value) => value);
109
+ }
110
+ },
111
+ secondaryBackground: Card (
112
+ shape: RoundedRectangleBorder (
113
+ borderRadius: BorderRadius .circular (20.0 )),
114
+ child: Center (
115
+ child: Text (
116
+ 'Delete' ,
117
+ style: TextStyle (
118
+ color: Colors .white, fontWeight: FontWeight .bold),
119
+ ),
120
+ ),
121
+ color: Colors .red,
122
+ ),
123
+ background: Card (
124
+ shape: RoundedRectangleBorder (
125
+ borderRadius: BorderRadius .circular (20.0 )),
126
+ child: Center (
127
+ child: Text (
128
+ 'Move To Finished' ,
129
+ style: TextStyle (
130
+ color: Colors .white, fontWeight: FontWeight .bold),
131
+ ),
132
+ ),
133
+ color: Colors .green,
134
+ ),
135
+ child: listItem (tasks[index]),
136
+ key: UniqueKey (),
137
+ );
150
138
},
151
139
separatorBuilder: (_, index) => Divider (
152
140
color: Colors .transparent,
0 commit comments