From 48bcf0b1f8fe989e15a3215441aaf9068eb18d8d Mon Sep 17 00:00:00 2001 From: Alzalia Date: Sat, 9 Aug 2025 12:11:54 +0200 Subject: [PATCH] fix: removed useless dependencies --- lib/data/repositories/auth_repository.dart | 3 +-- lib/data/services/api_client.dart | 12 ++---------- lib/data/services/auth_client.dart | 3 +-- lib/data/services/websocket_client.dart | 9 --------- lib/ui/add_page/view_model/add_view_model.dart | 5 +---- lib/ui/add_page/widgets/add_page.dart | 2 -- lib/ui/add_page/widgets/confirmation_popup.dart | 2 -- lib/ui/add_page/widgets/form_popup.dart | 2 -- lib/ui/add_page/widgets/owner_popup.dart | 1 - lib/ui/auth/viewmodel/login_view_model.dart | 3 --- 10 files changed, 5 insertions(+), 37 deletions(-) diff --git a/lib/data/repositories/auth_repository.dart b/lib/data/repositories/auth_repository.dart index 439d219..747e161 100644 --- a/lib/data/repositories/auth_repository.dart +++ b/lib/data/repositories/auth_repository.dart @@ -35,8 +35,7 @@ class AuthRepository extends ChangeNotifier { case Error(): return Result.error(result.error); } - } catch (e, stackTrace) { - debugPrintStack(stackTrace: stackTrace); + } catch (e) { return Result.error(Exception(e)); } } diff --git a/lib/data/services/api_client.dart b/lib/data/services/api_client.dart index c6ccf82..a32a001 100644 --- a/lib/data/services/api_client.dart +++ b/lib/data/services/api_client.dart @@ -1,6 +1,5 @@ import 'dart:convert'; -import 'package:flutter/cupertino.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:http/http.dart'; import 'package:seshat/config/constants.dart'; @@ -50,17 +49,13 @@ class ApiClient { Uri.parse("https://$apiBasePath/book/ean/$ean"), headers: headers, ); - debugPrint("\n\n\n\nGOT : ${response.statusCode}\n\n\n\n"); if (response.statusCode == 200) { - debugPrint("\n\n\n\nWITH : ${response.body}\n\n\n\n"); final json = jsonDecode(response.body); return Result.ok(Book.fromJSON(json)); } else { - debugPrintStack(); return Result.error(Exception("The book was not found")); } - } catch (e, stackTrace) { - debugPrintStack(stackTrace: stackTrace); + } catch (e) { return Result.error(Exception("API $e")); } finally { client.close(); @@ -88,7 +83,6 @@ class ApiClient { "owner_id": owner.id, "price": price, }); - debugPrint("\n\n\n\nSENDING : ${body}\n\n\n\n"); final response = await client.post( Uri.parse("https://$apiBasePath/book_instance"), headers: headers, @@ -96,15 +90,13 @@ class ApiClient { ); if (response.statusCode == 201) { final json = jsonDecode(response.body); - debugPrint("\n\n\n\nRECEIVED : ${json}\n\n\n\n"); return Result.ok(BookInstance.fromJSON(json)); } else if (response.statusCode == 403) { return Result.error(Exception("You don't own that book instance")); } else { return Result.error(Exception("Something wrong happened")); } - } catch (e, stack) { - debugPrintStack(stackTrace: stack); + } catch (e) { return Result.error(Exception(e)); } finally { client.close(); diff --git a/lib/data/services/auth_client.dart b/lib/data/services/auth_client.dart index 0d68094..1790346 100644 --- a/lib/data/services/auth_client.dart +++ b/lib/data/services/auth_client.dart @@ -1,6 +1,5 @@ import 'dart:convert'; -import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:seshat/config/constants.dart'; import 'package:seshat/utils/result.dart'; @@ -61,7 +60,7 @@ class AuthClient { } else { return Result.error(Exception("Token creation error")); } - } catch (e, stackTrace) { + } catch (e) { return Result.error(Exception(e)); } finally { client.close(); diff --git a/lib/data/services/websocket_client.dart b/lib/data/services/websocket_client.dart index 80d7f80..f8df18a 100644 --- a/lib/data/services/websocket_client.dart +++ b/lib/data/services/websocket_client.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:convert'; -import 'package:flutter/foundation.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:rxdart/rxdart.dart'; import 'package:seshat/config/constants.dart'; @@ -27,32 +26,24 @@ class WebsocketClient { Future connect() async { await _initStore(); - debugPrint("\n\n\n\nWEBSOCKET STORE IS READY\n\n\n\n"); if (_channel != null) return; - debugPrint("\n\n\n\nWEBSOCKET WILL CONNECT\n\n\n\n"); _channel = WebSocketChannel.connect(Uri.parse("wss://$apiBasePath/ws")); - debugPrint("\n\n\n\nWEBSOCKET IS CONNECTING\n\n\n\n"); await _channel!.ready; - debugPrint("\n\n\n\nWEBSOCKET IS READY\n\n\n\n"); var token = await _secureStorage!.read(key: "token"); _channel!.sink.add(jsonEncode({"token": "$token"})); _channel!.stream.listen((message) { - debugPrint("\n\n\n\n[1] Received : $message\n\n\n\n"); _baseController.add(message); }); var data = await _baseController.stream.first; - debugPrint("\n\n\n\n$data\n\n\n\n"); var result = jsonDecode(data); if (result["type"] == "auth_success") { - debugPrint("\n\n\n\nSUCCESS !\n\n\n\n"); sub = _baseController.stream.listen( (message) { final Map data = jsonDecode(message); - debugPrint("\n\n\n\n[2] Transfered : $message\n\n\n\n"); switch (data["type"]) { case "new_owner": final owner = Owner.fromJSON(data["data"]); diff --git a/lib/ui/add_page/view_model/add_view_model.dart b/lib/ui/add_page/view_model/add_view_model.dart index c332563..939d88e 100644 --- a/lib/ui/add_page/view_model/add_view_model.dart +++ b/lib/ui/add_page/view_model/add_view_model.dart @@ -49,7 +49,6 @@ class AddViewModel extends ChangeNotifier { String lastName, String contact, ) async { - debugPrint("\n\n\n\n(2) TRANFERRING\n\n\n\n"); final result = await _ownerRepository.addOwner( firstName, lastName, @@ -62,9 +61,7 @@ class AddViewModel extends ChangeNotifier { switch (secondResult) { case Ok(): - debugPrint("\n\n\n${secondResult.value.length}"); _owners = secondResult.value; - debugPrint("\n\n\n${_owners.length}"); _currentOwner = result.value; notifyListeners(); return Result.ok(result.value); @@ -142,7 +139,7 @@ class AddViewModel extends ChangeNotifier { ); isLoaded = true; case Error(): - debugPrint("Oupsie daysie, ${result.error}"); + break; } notifyListeners(); diff --git a/lib/ui/add_page/widgets/add_page.dart b/lib/ui/add_page/widgets/add_page.dart index 26789ec..b74ff70 100644 --- a/lib/ui/add_page/widgets/add_page.dart +++ b/lib/ui/add_page/widgets/add_page.dart @@ -75,8 +75,6 @@ class _AddPageState extends State { ); break; case Error(): - debugPrintStack(); - debugPrint(result.error.toString()); ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text("Erreur : ${result.error}"), diff --git a/lib/ui/add_page/widgets/confirmation_popup.dart b/lib/ui/add_page/widgets/confirmation_popup.dart index a218f62..55816a9 100644 --- a/lib/ui/add_page/widgets/confirmation_popup.dart +++ b/lib/ui/add_page/widgets/confirmation_popup.dart @@ -1,5 +1,3 @@ -import 'dart:ffi'; - import 'package:flutter/material.dart'; import 'package:seshat/domain/models/bal.dart'; import 'package:seshat/domain/models/book.dart'; diff --git a/lib/ui/add_page/widgets/form_popup.dart b/lib/ui/add_page/widgets/form_popup.dart index 0617fd2..341b247 100644 --- a/lib/ui/add_page/widgets/form_popup.dart +++ b/lib/ui/add_page/widgets/form_popup.dart @@ -23,7 +23,6 @@ class FormPopup extends StatelessWidget { child: InkWell( splashColor: Colors.blue.withAlpha(30), onTap: () { - debugPrint('Card tapped.'); Navigator.of(context).pop(); showDialog( context: context, @@ -57,7 +56,6 @@ class FormPopup extends StatelessWidget { child: InkWell( splashColor: Colors.blue.withAlpha(30), onTap: () { - debugPrint('Card tapped.'); Navigator.of(context).pop(); showDialog( context: context, diff --git a/lib/ui/add_page/widgets/owner_popup.dart b/lib/ui/add_page/widgets/owner_popup.dart index a03f928..c7b76cd 100644 --- a/lib/ui/add_page/widgets/owner_popup.dart +++ b/lib/ui/add_page/widgets/owner_popup.dart @@ -154,7 +154,6 @@ class _OwnerPopupState extends State { if (showNewOwner) { if (_formKey.currentState!.validate()) { _formKey.currentState!.save(); - debugPrint("\n\n\n\n(1) SENDING REQUEST\n\n\n\n"); await widget.viewModel.addOwner( firstName!, lastName!, diff --git a/lib/ui/auth/viewmodel/login_view_model.dart b/lib/ui/auth/viewmodel/login_view_model.dart index 844e3e8..df0a91f 100644 --- a/lib/ui/auth/viewmodel/login_view_model.dart +++ b/lib/ui/auth/viewmodel/login_view_model.dart @@ -16,9 +16,6 @@ class LoginViewModel extends ChangeNotifier { Future> _login((String, String) credentials) async { final (username, password) = credentials; final result = await _authRepository.login(username, password); - if (result is Error) { - debugPrint("Hehe no"); - } return result; } }