2
2
3
3
import 'dart:convert' ;
4
4
import 'package:flutter/foundation.dart' ;
5
+ import 'package:flutter/material.dart' ;
5
6
import 'package:http/http.dart' as http;
6
7
import 'package:sqflite/sqflite.dart' ;
7
8
import 'package:path/path.dart' ;
@@ -205,6 +206,11 @@ Future<void> completeTask(String email, String taskUuid) async {
205
206
debugPrint ('Task completed successfully on server' );
206
207
} else {
207
208
debugPrint ('Failed to complete task: ${response .statusCode }' );
209
+ ScaffoldMessenger .of (context as BuildContext ).showSnackBar (const SnackBar (
210
+ content: Text (
211
+ "Failed to complete task!" ,
212
+ style: TextStyle (color: Colors .red),
213
+ )));
208
214
}
209
215
} catch (e) {
210
216
debugPrint ('Error completing task: $e ' );
@@ -250,7 +256,7 @@ Future<void> modifyTaskOnTaskwarrior(String description, String project,
250
256
var e = await CredentialsStorage .getEncryptionSecret ();
251
257
debugPrint (c);
252
258
debugPrint (e);
253
- await http.post (
259
+ final response = await http.post (
254
260
Uri .parse (apiUrl),
255
261
headers: {
256
262
'Content-Type' : 'text/plain' ,
@@ -268,6 +274,14 @@ Future<void> modifyTaskOnTaskwarrior(String description, String project,
268
274
}),
269
275
);
270
276
277
+ if (response.statusCode != 200 ) {
278
+ ScaffoldMessenger .of (context as BuildContext ).showSnackBar (const SnackBar (
279
+ content: Text (
280
+ "Failed to update task!" ,
281
+ style: TextStyle (color: Colors .red),
282
+ )));
283
+ }
284
+
271
285
var taskDatabase = TaskDatabase ();
272
286
await taskDatabase.open ();
273
287
await taskDatabase._database! .delete (
0 commit comments