Skip to content

Commit

Permalink
fix: delete card
Browse files Browse the repository at this point in the history
  • Loading branch information
PikPakPik committed Mar 21, 2024
1 parent 754f66f commit 78e8d1c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
10 changes: 1 addition & 9 deletions lib/repositories/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,7 @@ Future<void> deleteCard(String apiKey, String? token, String cardId) async {
'https://api.trello.com/1/cards/$cardId?key=$apiKey&token=$token'),
);

if (response.statusCode == 200) {
Fluttertoast.showToast(
msg: "Suppression effectuée",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.red,
textColor: Colors.white,
);
} else {
if (response.statusCode != 200) {
throw Exception('Failed to delete card');
}
}
Expand Down
50 changes: 36 additions & 14 deletions lib/views/board/board_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,42 @@ class BoardViewState extends State<BoardView> {
color: Colors
.white,
),
onPressed: () => {
// _deleteCard(snapshot.data![index].id),
setState(
() async {
deleteCard(
dotenv.env[
'TRELLO_API_KEY']!,
await getAccessToken(),
snapshot
.data![
index]
.id);
_editList =
false;
onPressed:
() async => {
deleteCard(
dotenv.env[
'TRELLO_API_KEY']!,
await getAccessToken(),
snapshot
.data![
index]
.id!)
.then(
(value) {
Fluttertoast.showToast(
msg:
'Carte supprimée avec succès',
toastLength:
Toast
.LENGTH_SHORT,
gravity: ToastGravity
.BOTTOM,
timeInSecForIosWeb:
1,
backgroundColor:
Colors
.green,
textColor:
Colors
.white,
fontSize:
16.0);
setState(() {
_getCardsByList(
snapshot
.data![index]
.id);
});
})
},
),
Expand Down

0 comments on commit 78e8d1c

Please sign in to comment.