From f42cfaac7cc6963d3bc4fe6e6af99486bb15be3e Mon Sep 17 00:00:00 2001 From: An Nguyen Date: Thu, 5 Aug 2021 12:23:32 +0700 Subject: [PATCH] Feat: Replace print by debugPrint for better performance --- lib/_crawler/bloc/crawler_bloc.dart | 12 ++++++------ lib/_models/calendar_client_model.dart | 11 ++++++----- lib/_preload/bloc/preload_bloc.dart | 6 +++--- .../src/authentication_repository.dart | 5 +++-- .../src/services/login_service.dart | 3 ++- .../src/firebase_repository.dart | 12 ++++++------ .../user_repository/src/user_repository.dart | 5 +++-- lib/_services/api/api_event_service.dart | 7 ++++--- lib/_services/api/api_exam_schedule_service.dart | 7 ++++--- lib/_services/api/api_notification_service.dart | 7 ++++--- lib/_services/api/api_score_service.dart | 7 ++++--- lib/_services/api/crawler_service.dart | 8 +++++--- lib/_services/api/token_service.dart | 9 +++++---- lib/_services/api/version_service.dart | 5 +++-- .../controller/event_service_controller.dart | 5 +++-- .../exam_schedule_service_controller.dart | 3 ++- .../notification_service_controller.dart | 5 +++-- .../controller/score_service_controller.dart | 3 ++- lib/_services/local/local_event_service.dart | 13 +++++++------ .../local/local_exam_schedule_service.dart | 3 ++- .../local/local_notification_service.dart | 3 ++- lib/_services/local/local_score_service.dart | 3 ++- lib/_services/model/service_response.dart | 3 ++- lib/_utils/database/provider.dart | 14 +++++++------- lib/_utils/database/table/data_version.dart | 3 ++- lib/_utils/database/table/db_color_event.dart | 5 +++-- lib/_utils/database/table/db_event.dart | 9 +++++---- lib/_utils/database/table/db_event_exam.dart | 5 +++-- lib/_utils/database/table/db_event_schedule.dart | 9 +++++---- lib/_utils/database/table/db_exam_schedule.dart | 3 ++- lib/_utils/database/table/db_notification.dart | 11 ++++++----- lib/_utils/database/table/db_schedule.dart | 9 +++++---- lib/_utils/database/table/db_score.dart | 3 ++- lib/_utils/database/table/db_sender.dart | 3 ++- lib/event_info/view/event_info_page.dart | 2 +- lib/exam_schedule/bloc/exam_schedule_bloc.dart | 4 ++-- lib/google_calendar_page.dart | 4 ++-- lib/main.dart | 2 +- lib/plan/view/local_widgets/add_guest.dart | 2 +- lib/score/bloc/score_bloc.dart | 4 ++-- 40 files changed, 134 insertions(+), 103 deletions(-) diff --git a/lib/_crawler/bloc/crawler_bloc.dart b/lib/_crawler/bloc/crawler_bloc.dart index 7c07012..03acc8e 100644 --- a/lib/_crawler/bloc/crawler_bloc.dart +++ b/lib/_crawler/bloc/crawler_bloc.dart @@ -80,7 +80,7 @@ class CrawlerBloc extends Bloc { ), ); - print('crawler_bloc.dart --- Update password: $passwordStatus'); + debugPrint('crawler_bloc.dart --- Update password: $passwordStatus'); if (passwordStatus.isOk) { bool hasError = false; @@ -94,7 +94,7 @@ class CrawlerBloc extends Bloc { all: true, ), ); - print('crawler_bloc.dart --- Crawl score: $scoreCrawlerStatus'); + debugPrint('crawler_bloc.dart --- Crawl score: $scoreCrawlerStatus'); if (scoreCrawlerStatus.isOk) { await userDataModel.scoreServiceController.refresh(); @@ -112,7 +112,7 @@ class CrawlerBloc extends Bloc { all: true, ), ); - print('crawler_bloc.dart --- Crawl exam Schedule: $examScheduleCrawlerStatus'); + debugPrint('crawler_bloc.dart --- Crawl exam Schedule: $examScheduleCrawlerStatus'); if (examScheduleCrawlerStatus.isOk) { await userDataModel.examScheduleServiceController.refresh(); @@ -158,9 +158,9 @@ class CrawlerBloc extends Bloc { ), ); - print(state.formStatus); + debugPrint(state.formStatus.toString()); - print('crawler_bloc.dart --- Crawl score: $scoreCrawlerStatus'); + debugPrint('crawler_bloc.dart --- Crawl score: $scoreCrawlerStatus'); if (scoreCrawlerStatus.isOk) { await userDataModel.scoreServiceController.refresh(); @@ -178,7 +178,7 @@ class CrawlerBloc extends Bloc { all: true, ), ); - print('crawler_bloc.dart --- Crawl exam Schedule: $examScheduleCrawlerStatus'); + debugPrint('crawler_bloc.dart --- Crawl exam Schedule: $examScheduleCrawlerStatus'); if (examScheduleCrawlerStatus.isOk) { await userDataModel.examScheduleServiceController.refresh(); diff --git a/lib/_models/calendar_client_model.dart b/lib/_models/calendar_client_model.dart index 69ff2cd..617a846 100644 --- a/lib/_models/calendar_client_model.dart +++ b/lib/_models/calendar_client_model.dart @@ -1,5 +1,6 @@ import 'dart:developer'; +import 'package:flutter/widgets.dart'; import 'package:googleapis_auth/auth_io.dart'; import 'package:googleapis/calendar/v3.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -13,7 +14,7 @@ class CalendarClientModel { var _clientID = ClientId(clientId, ""); clientViaUserConsent(_clientID, _scopes, prompt).then((AuthClient client) { var calendar = CalendarApi(client); - calendar.calendarList.list().then((value) => print("VAL________$value")); + calendar.calendarList.list().then((value) => debugPrint("VAL________$value")); String calendarId = "primary"; Event event = Event(); @@ -32,7 +33,7 @@ class CalendarClientModel { try { calendar.events.insert(event, calendarId).then((value) { - print("ADDED_________________${value.status}"); + debugPrint("ADDED_________________${value.status}"); if (value.status == "confirmed") { log('Event added in google calendar'); } else { @@ -46,9 +47,9 @@ class CalendarClientModel { } void prompt(String url) async { - print("Please go to the following URL and grant access:"); - print(" => $url"); - print(""); + debugPrint("Please go to the following URL and grant access:"); + debugPrint(" => $url"); + debugPrint(""); if (await canLaunch(url)) { await launch(url); diff --git a/lib/_preload/bloc/preload_bloc.dart b/lib/_preload/bloc/preload_bloc.dart index d5f4308..12bbc7f 100644 --- a/lib/_preload/bloc/preload_bloc.dart +++ b/lib/_preload/bloc/preload_bloc.dart @@ -82,7 +82,7 @@ class PreloadBloc extends Bloc { final timeEnded = stopwatch.elapsed; stopwatch.stop(); - print(timeEnded); + debugPrint(timeEnded.toString()); final userDataModel = UserDataModel( eventServiceController: serviceControllers.event, @@ -127,7 +127,7 @@ class PreloadBloc extends Bloc { final timeEnded = stopwatch.elapsed; stopwatch.stop(); - print(timeEnded); + debugPrint(timeEnded.toString()); final userDataModel = UserDataModel( eventServiceController: serviceControllers.event, @@ -169,7 +169,7 @@ class PreloadBloc extends Bloc { ).getServerDataVersion(); if (versionMap.isNotEmpty) { - print(versionMap); + debugPrint(versionMap.toString()); if (force) { await serviceControllers.forceRefresh(versionMap); } else { diff --git a/lib/_repositories/authentication_repository/src/authentication_repository.dart b/lib/_repositories/authentication_repository/src/authentication_repository.dart index 46fd960..dfcfbd1 100644 --- a/lib/_repositories/authentication_repository/src/authentication_repository.dart +++ b/lib/_repositories/authentication_repository/src/authentication_repository.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:app_qldt/_models/account_permission_enum.dart'; import 'package:app_qldt/_utils/database/provider.dart'; import 'package:app_qldt/_utils/secret/url/url.dart'; +import 'package:flutter/widgets.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'services/services.dart'; @@ -35,7 +36,7 @@ class AuthenticationRepository { final LoginResponse loginResponse = await _loginService!.login(loginUser); - print('Login status: ${loginResponse.status}, permission: ${apiUrl.accountPermission}'); + debugPrint('Login status: ${loginResponse.status}, permission: ${apiUrl.accountPermission}'); if (loginResponse.status.isSuccessfully) { await _saveUserInfo(loginResponse.data!, apiUrl.accountPermission); @@ -54,7 +55,7 @@ class AuthenticationRepository { } Future logOut() async { - print('${DateTime.now()}: Request to logout'); + debugPrint('${DateTime.now()}: Request to logout'); await DatabaseProvider.deleteDb(); await _removeUserInfo(); diff --git a/lib/_repositories/authentication_repository/src/services/login_service.dart b/lib/_repositories/authentication_repository/src/services/login_service.dart index aab6fe6..a4047c4 100644 --- a/lib/_repositories/authentication_repository/src/services/login_service.dart +++ b/lib/_repositories/authentication_repository/src/services/login_service.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:app_qldt/_utils/helper/const.dart'; import 'package:app_qldt/_utils/secret/url/url.dart'; import 'package:connectivity/connectivity.dart'; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; import 'models/models.dart'; @@ -40,7 +41,7 @@ class LoginService { data: status.isSuccessfully ? response.body : null, ); } on Exception catch (e) { - print('Error: $e in Login service'); + debugPrint('Error: $e in Login service'); return LoginResponse(status: LoginStatus.serverError); } } diff --git a/lib/_repositories/firebase_repository/src/firebase_repository.dart b/lib/_repositories/firebase_repository/src/firebase_repository.dart index cbead28..30087c0 100644 --- a/lib/_repositories/firebase_repository/src/firebase_repository.dart +++ b/lib/_repositories/firebase_repository/src/firebase_repository.dart @@ -1,4 +1,5 @@ import 'package:firebase_messaging/firebase_messaging.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; class FirebaseRepository { @@ -25,8 +26,7 @@ class FirebaseRepository { importance: Importance.max, ); - final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = - FlutterLocalNotificationsPlugin(); + final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings('mipmap/ic_launcher'); @@ -45,8 +45,8 @@ class FirebaseRepository { RemoteNotification? notification = message.notification; AndroidNotification? android = message.notification?.android; - print(message.data); - print(message.notification); + debugPrint(message.data.toString()); + debugPrint(message.notification.toString()); if (notification != null && android != null) { flutterLocalNotificationsPlugin.show( @@ -72,11 +72,11 @@ class FirebaseRepository { } Future getToken() async { - print('Getting token'); + debugPrint('Getting token'); try { return await FirebaseMessaging.instance.getToken(); } on Exception catch (e) { - print('Get token error: $e'); + debugPrint('Get token error: $e'); } } } diff --git a/lib/_repositories/user_repository/src/user_repository.dart b/lib/_repositories/user_repository/src/user_repository.dart index 43312ff..5cd7b9c 100644 --- a/lib/_repositories/user_repository/src/user_repository.dart +++ b/lib/_repositories/user_repository/src/user_repository.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:app_qldt/_models/account_permission_enum.dart'; import 'package:app_qldt/_models/user_data_model.dart'; +import 'package:flutter/widgets.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'models/models.dart'; @@ -16,13 +17,13 @@ class UserRepository { if (loginInfo.isEmpty) return null; - print(loginInfo); + debugPrint(loginInfo.toString()); try { final permission = await _getPermission(); _user = User.fromJsonWithPermission(loginInfo, permission); } on Exception catch (e){ - print(e.toString()); + debugPrint(e.toString()); } return _user; diff --git a/lib/_services/api/api_event_service.dart b/lib/_services/api/api_event_service.dart index 4e771d3..f0ff18d 100644 --- a/lib/_services/api/api_event_service.dart +++ b/lib/_services/api/api_event_service.dart @@ -6,6 +6,7 @@ import 'package:app_qldt/_services/model/service_response.dart'; import 'package:app_qldt/_utils/helper/const.dart'; import 'package:app_qldt/_utils/secret/url/url.dart'; import 'package:connectivity/connectivity.dart'; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; class ApiEventService extends ApiService { @@ -46,11 +47,11 @@ class ApiEventService extends ApiService { http.Response response = await http.get(Uri.parse(url)).timeout(Const.requestTimeout); return ServiceResponse.withVersion(response); } on TimeoutException catch (e) { - print('Timeout error: $e at Event service'); + debugPrint('Timeout error: $e at Event service'); } on SocketException catch (e) { - print('Socket error: $e at Event service'); + debugPrint('Socket error: $e at Event service'); } on Error catch (e) { - print('General Error: $e at Event service'); + debugPrint('General Error: $e at Event service'); } return ServiceResponse.error(); diff --git a/lib/_services/api/api_exam_schedule_service.dart b/lib/_services/api/api_exam_schedule_service.dart index 708151e..93c1c65 100644 --- a/lib/_services/api/api_exam_schedule_service.dart +++ b/lib/_services/api/api_exam_schedule_service.dart @@ -6,6 +6,7 @@ import 'package:app_qldt/_services/model/service_response.dart'; import 'package:app_qldt/_utils/helper/const.dart'; import 'package:app_qldt/_utils/secret/url/url.dart'; import 'package:connectivity/connectivity.dart'; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; @@ -50,11 +51,11 @@ class ApiExamScheduleService extends ApiService { final response = await http.get(Uri.parse(url)).timeout(Const.requestTimeout); return ServiceResponse(response); } on TimeoutException catch (e) { - print('Timeout error: $e at ExamSchedule service'); + debugPrint('Timeout error: $e at ExamSchedule service'); } on SocketException catch (e) { - print('Socket error: $e at ExamSchedule service'); + debugPrint('Socket error: $e at ExamSchedule service'); } on Error catch (e) { - print('General Error: $e at ExamSchedule service'); + debugPrint('General Error: $e at ExamSchedule service'); } return ServiceResponse.error(); diff --git a/lib/_services/api/api_notification_service.dart b/lib/_services/api/api_notification_service.dart index 4eed2e1..a9a0d03 100644 --- a/lib/_services/api/api_notification_service.dart +++ b/lib/_services/api/api_notification_service.dart @@ -6,6 +6,7 @@ import 'package:app_qldt/_services/model/service_response.dart'; import 'package:app_qldt/_utils/helper/const.dart'; import 'package:app_qldt/_utils/secret/url/url.dart'; import 'package:connectivity/connectivity.dart'; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; class ApiNotificationService extends ApiService { @@ -50,11 +51,11 @@ class ApiNotificationService extends ApiService { final response = await http.get(Uri.parse(url)).timeout(Const.requestTimeout); return ServiceResponse.withVersion(response); } on TimeoutException catch (e) { - print('Timeout error: $e at API Notification service'); + debugPrint('Timeout error: $e at API Notification service'); } on SocketException catch (e) { - print('Socket error: $e at API Notification service'); + debugPrint('Socket error: $e at API Notification service'); } on Error catch (e) { - print('General Error: $e at API Notification service'); + debugPrint('General Error: $e at API Notification service'); } return ServiceResponse.error(); diff --git a/lib/_services/api/api_score_service.dart b/lib/_services/api/api_score_service.dart index 84d3cf0..d30ce20 100644 --- a/lib/_services/api/api_score_service.dart +++ b/lib/_services/api/api_score_service.dart @@ -6,6 +6,7 @@ import 'package:app_qldt/_services/model/service_response.dart'; import 'package:app_qldt/_utils/helper/const.dart'; import 'package:app_qldt/_utils/secret/url/url.dart'; import 'package:connectivity/connectivity.dart'; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; class ApiScoreService extends ApiService { @@ -48,11 +49,11 @@ class ApiScoreService extends ApiService { final response = await http.get(Uri.parse(url)).timeout(Const.requestTimeout); return ServiceResponse(response); } on TimeoutException catch (e) { - print('Timeout error: $e at Score service'); + debugPrint('Timeout error: $e at Score service'); } on SocketException catch (e) { - print('Socket error: $e at Score service'); + debugPrint('Socket error: $e at Score service'); } on Error catch (e) { - print('General Error: $e at Score service'); + debugPrint('General Error: $e at Score service'); } return ServiceResponse.error(); diff --git a/lib/_services/api/crawler_service.dart b/lib/_services/api/crawler_service.dart index 437dc2b..b861f91 100644 --- a/lib/_services/api/crawler_service.dart +++ b/lib/_services/api/crawler_service.dart @@ -6,6 +6,7 @@ import 'package:app_qldt/_models/crawler/score_crawler_model.dart'; import 'package:app_qldt/_models/crawler/update_password_crawler_model.dart'; import 'package:app_qldt/_utils/helper/const.dart'; import 'package:app_qldt/_utils/secret/url/url.dart'; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; class CrawlerService { @@ -22,10 +23,11 @@ class CrawlerService { response = await http.post(Uri.parse(url), body: body).timeout(Const.crawlerTimeout); return CrawlerStatusExtension.fromStatusCode(response.statusCode); } on Exception catch (e) { - print('Error: $e in Crawler service - Update password'); + debugPrint('Error: $e in Crawler service - Update password'); return CrawlerStatus.serverError; } } + Future crawlScore(ScoreCrawlerModel crawler) async { String url = apiUrl.post.scoreCrawler; String body = jsonEncode(crawler); @@ -35,7 +37,7 @@ class CrawlerService { response = await http.post(Uri.parse(url), body: body).timeout(Const.crawlerTimeout); return CrawlerStatusExtension.fromStatusCode(response.statusCode); } on Exception catch (e) { - print('Error: $e in Crawler service - Crawl score'); + debugPrint('Error: $e in Crawler service - Crawl score'); return CrawlerStatus.serverError; } } @@ -49,7 +51,7 @@ class CrawlerService { response = await http.post(Uri.parse(url), body: body).timeout(Const.crawlerTimeout); return CrawlerStatusExtension.fromStatusCode(response.statusCode); } on Exception catch (e) { - print('Error: $e in Crawler service - Crawl exam schedule'); + debugPrint('Error: $e in Crawler service - Crawl exam schedule'); return CrawlerStatus.serverError; } } diff --git a/lib/_services/api/token_service.dart b/lib/_services/api/token_service.dart index 0e361f7..51282c7 100644 --- a/lib/_services/api/token_service.dart +++ b/lib/_services/api/token_service.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'package:connectivity/connectivity.dart'; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; import 'package:app_qldt/_utils/helper/const.dart'; @@ -19,7 +20,7 @@ class TokenService { Future upsert(String studentId) async { if (await Connectivity().checkConnectivity() != ConnectivityResult.none) { String? token = await _firebaseRepository.getToken(); - print('Token: $token'); + debugPrint('Token: $token'); final json = { 'id_student': studentId, @@ -36,13 +37,13 @@ class TokenService { ) .timeout(Const.requestTimeout); } on Exception catch (e) { - print('Error: $e in Token service'); + debugPrint('Error: $e in Token service'); return; } - print('Upsert token status: ${response.body}'); + debugPrint('Upsert token status: ${response.body}'); } else { - print('Token Service: Do not upsert since no internet connection'); + debugPrint('Token Service: Do not upsert since no internet connection'); } } } diff --git a/lib/_services/api/version_service.dart b/lib/_services/api/version_service.dart index a60395a..84d04fd 100644 --- a/lib/_services/api/version_service.dart +++ b/lib/_services/api/version_service.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:app_qldt/_utils/helper/const.dart'; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; import 'package:app_qldt/_utils/secret/url/url.dart'; @@ -19,13 +20,13 @@ class VersionService { http.Response response; String url = '$baseUrl?id=$idStudent'; - print(url); + debugPrint(url); try { response = await http.get(Uri.parse(url)).timeout(Const.requestTimeout); return jsonDecode(response.body); } on Exception catch (e) { - print('Error: $e in Version service - getServerDataVersion()'); + debugPrint('Error: $e in Version service - getServerDataVersion()'); return {}; } } diff --git a/lib/_services/controller/event_service_controller.dart b/lib/_services/controller/event_service_controller.dart index 27ac301..5a9c6ff 100644 --- a/lib/_services/controller/event_service_controller.dart +++ b/lib/_services/controller/event_service_controller.dart @@ -7,6 +7,7 @@ import 'package:app_qldt/_services/api/api_event_service.dart'; import 'package:app_qldt/_services/controller/service_controller.dart'; import 'package:app_qldt/_services/local/local_event_service.dart'; import 'package:app_qldt/_services/model/service_response.dart'; +import 'package:flutter/widgets.dart'; class EventServiceController extends ServiceController { EventServiceController(ServiceControllerData data) @@ -33,9 +34,9 @@ class EventServiceController extends ServiceController { @@ -35,7 +36,7 @@ class ExamScheduleServiceController if (response.statusCode == 204 && localService.databaseProvider.dataVersion.examSchedule > 0) { setConnected(); } else { - print('Error with status code: ${response.statusCode} at exam_schedule_service_controller.dart'); + debugPrint('Error with status code: ${response.statusCode} at exam_schedule_service_controller.dart'); } } } diff --git a/lib/_services/controller/notification_service_controller.dart b/lib/_services/controller/notification_service_controller.dart index 391f2fa..54fb141 100644 --- a/lib/_services/controller/notification_service_controller.dart +++ b/lib/_services/controller/notification_service_controller.dart @@ -5,6 +5,7 @@ import 'package:app_qldt/_services/api/api_notification_service.dart'; import 'package:app_qldt/_services/controller/service_controller.dart'; import 'package:app_qldt/_services/local/local_notification_service.dart'; import 'package:app_qldt/_services/model/service_response.dart'; +import 'package:flutter/widgets.dart'; class NotificationServiceController extends ServiceController { @@ -37,9 +38,9 @@ class NotificationServiceController await localService.updateVersion(response.version!); } else { if (response.statusCode == 204) { - print('There are no new data'); + debugPrint('There are no new data'); } else { - print('Error with status code: ${response.statusCode} at notification_service_controller.dart'); + debugPrint('Error with status code: ${response.statusCode} at notification_service_controller.dart'); } } } diff --git a/lib/_services/controller/score_service_controller.dart b/lib/_services/controller/score_service_controller.dart index 5a192a2..6ddc8a1 100644 --- a/lib/_services/controller/score_service_controller.dart +++ b/lib/_services/controller/score_service_controller.dart @@ -6,6 +6,7 @@ import 'package:app_qldt/_services/controller/service_controller.dart'; import 'package:app_qldt/_services/local/local_score_service.dart'; import 'package:app_qldt/_services/model/service_response.dart'; import 'package:app_qldt/score/bloc/enum/subject_status.dart'; +import 'package:flutter/widgets.dart'; class ScoreServiceController extends ServiceController { ScoreServiceController(ServiceControllerData data) @@ -36,7 +37,7 @@ class ScoreServiceController extends ServiceController 0) { setConnected(); } else { - print('Error with status code: ${response.statusCode} at score_service_controller.dart'); + debugPrint('Error with status code: ${response.statusCode} at score_service_controller.dart'); } } } diff --git a/lib/_services/local/local_event_service.dart b/lib/_services/local/local_event_service.dart index 584e6e8..e6a5526 100644 --- a/lib/_services/local/local_event_service.dart +++ b/lib/_services/local/local_event_service.dart @@ -7,6 +7,7 @@ import 'package:app_qldt/_services/controller/event_service_controller.dart'; import 'package:app_qldt/_services/controller/service_controller.dart'; import 'package:app_qldt/_services/local/local_service.dart'; import 'package:app_qldt/_utils/database/provider.dart'; +import 'package:flutter/widgets.dart'; /// This class used for saving data about events (or schedules) /// into local storage @@ -38,7 +39,7 @@ class LocalEventService extends LocalService { /// 4. Return data. /// Future saveNewData(List newData) async { - print('Event service: Updating new data'); + debugPrint('Event service: Updating new data'); await _remove(); await _save(newData); @@ -80,27 +81,27 @@ class LocalEventService extends LocalService { } Future saveNewEvent(UserEventModel event) async { - print('Adding event: $event'); + debugPrint('Adding event: $event'); return await databaseProvider.event.insert(event.toMap()); } Future saveModifiedEvent(EventModel event) async { - print('Modifying schedule: $event'); + debugPrint('Modifying schedule: $event'); await databaseProvider.event.update(event.toMap()); } Future saveModifiedSchedule(EventScheduleModel event) async { - print('Modifying schedule: $event'); + debugPrint('Modifying schedule: $event'); await databaseProvider.eventSchedule.update(event.toMap()); } Future saveAllModifiedScheduleWithName(String name, EventScheduleModel event) async { - print('Modifying all schedules with name $name: $event'); + debugPrint('Modifying all schedules with name $name: $event'); await databaseProvider.eventSchedule.updateWithName(name, event.toMap()); } Future deleteEvent(int id) async { - print('Deleting schedule has id: $id'); + debugPrint('Deleting schedule has id: $id'); await databaseProvider.event.delete(id); } diff --git a/lib/_services/local/local_exam_schedule_service.dart b/lib/_services/local/local_exam_schedule_service.dart index 65ec4e8..716b049 100644 --- a/lib/_services/local/local_exam_schedule_service.dart +++ b/lib/_services/local/local_exam_schedule_service.dart @@ -1,3 +1,4 @@ +import 'package:flutter/widgets.dart'; import 'package:intl/intl.dart'; import 'package:app_qldt/_models/exam_schedule_model.dart'; @@ -21,7 +22,7 @@ class LocalExamScheduleService extends LocalService { controller as ExamScheduleServiceController; Future?> saveNewData(List newData) async { - print('ExamSchedule service: Updating new data'); + debugPrint('ExamSchedule service: Updating new data'); await _removeOld(); await _saveNew(newData); diff --git a/lib/_services/local/local_notification_service.dart b/lib/_services/local/local_notification_service.dart index bf63d7b..30801bf 100644 --- a/lib/_services/local/local_notification_service.dart +++ b/lib/_services/local/local_notification_service.dart @@ -6,6 +6,7 @@ import 'package:app_qldt/_services/controller/notification_service_controller.da import 'package:app_qldt/_services/controller/service_controller.dart'; import 'package:app_qldt/_services/local/local_service.dart'; import 'package:app_qldt/_utils/database/provider.dart'; +import 'package:flutter/widgets.dart'; class LocalNotificationService extends LocalService { List notificationData = []; @@ -21,7 +22,7 @@ class LocalNotificationService extends LocalService { List? notificationList, List? deleteList, ) async { - print('Notification service: Updating new data'); + debugPrint('Notification service: Updating new data'); await _saveNotification(notificationList); await _saveSender(senderList); diff --git a/lib/_services/local/local_score_service.dart b/lib/_services/local/local_score_service.dart index bc367f2..40feef7 100644 --- a/lib/_services/local/local_score_service.dart +++ b/lib/_services/local/local_score_service.dart @@ -5,6 +5,7 @@ import 'package:app_qldt/_services/controller/score_service_controller.dart'; import 'package:app_qldt/_services/controller/service_controller.dart'; import 'package:app_qldt/_services/local/local_service.dart'; import 'package:app_qldt/_utils/database/provider.dart'; +import 'package:flutter/widgets.dart'; class LocalScoreService extends LocalService { List scoreData = []; @@ -15,7 +16,7 @@ class LocalScoreService extends LocalService { LocalScoreService({DatabaseProvider? databaseProvider}) : super(databaseProvider); Future> saveNewData(List newData) async { - print('Score service: Updating new data'); + debugPrint('Score service: Updating new data'); await _removeOld(); await _saveNew(newData); diff --git a/lib/_services/model/service_response.dart b/lib/_services/model/service_response.dart index 374527b..970aabd 100644 --- a/lib/_services/model/service_response.dart +++ b/lib/_services/model/service_response.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart'; class ServiceResponse { @@ -19,7 +20,7 @@ class ServiceResponse { data = body['data']; version = body['data_version']; } on Exception catch (e) { - print('$e in ServiceResponse._()'); + debugPrint('$e in ServiceResponse._()'); } } } diff --git a/lib/_utils/database/provider.dart b/lib/_utils/database/provider.dart index 7648a78..45e248d 100644 --- a/lib/_utils/database/provider.dart +++ b/lib/_utils/database/provider.dart @@ -5,6 +5,7 @@ import 'package:app_qldt/_utils/database/table/db_event.dart'; import 'package:app_qldt/_utils/database/table/db_event_exam.dart'; import 'package:app_qldt/_utils/database/table/db_event_schedule.dart'; import 'package:app_qldt/_utils/database/table/db_exam_schedule.dart'; +import 'package:flutter/widgets.dart'; import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; @@ -30,10 +31,10 @@ class DatabaseProvider { await _initDb(); await _initTables(); - print('DbProvider: Schedule version ${dataVersion.schedule}'); - print('DbProvider: Notification version ${dataVersion.notification}'); - print('DbProvider: ExamSchedule version ${dataVersion.examSchedule}'); - print('DbProvider: Score version ${dataVersion.score}'); + debugPrint('DbProvider: Schedule version ${dataVersion.schedule}'); + debugPrint('DbProvider: Notification version ${dataVersion.notification}'); + debugPrint('DbProvider: ExamSchedule version ${dataVersion.examSchedule}'); + debugPrint('DbProvider: Score version ${dataVersion.score}'); } Future _initDb() async { @@ -103,9 +104,8 @@ class DatabaseProvider { var dv = DbDataVersion(); dv.create(db); DbDataVersion.insertInitial(db); - } on Exception catch (e) { - print('$e in DatabaseProvider._onCreate()'); + debugPrint('$e in DatabaseProvider._onCreate()'); } } @@ -115,7 +115,7 @@ class DatabaseProvider { await _upgradeToV2(db); } } on Exception catch (e) { - print('$e in DatabaseProvider._onUpgrade()'); + debugPrint('$e in DatabaseProvider._onUpgrade()'); } } diff --git a/lib/_utils/database/table/data_version.dart b/lib/_utils/database/table/data_version.dart index 673211b..ac06539 100644 --- a/lib/_utils/database/table/data_version.dart +++ b/lib/_utils/database/table/data_version.dart @@ -1,4 +1,5 @@ import 'package:app_qldt/_utils/database/table/table_model.dart'; +import 'package:flutter/widgets.dart'; import 'package:sqflite/sqflite.dart'; class DbDataVersion extends TableModel { @@ -126,7 +127,7 @@ class DbDataVersion extends TableModel { try { await database!.delete(tableName); } on Exception catch (e) { - print('Error: ${e.toString()}'); + debugPrint('Error: ${e.toString()}'); } } } diff --git a/lib/_utils/database/table/db_color_event.dart b/lib/_utils/database/table/db_color_event.dart index e59089d..6650d32 100644 --- a/lib/_utils/database/table/db_color_event.dart +++ b/lib/_utils/database/table/db_color_event.dart @@ -1,3 +1,4 @@ +import 'package:flutter/widgets.dart'; import 'package:sqflite/sqflite.dart'; import 'table_model.dart'; @@ -24,7 +25,7 @@ class DbColorEvent extends TableModel { 'color_event;', ); } on Exception catch (e) { - print('$e in DbColorEvent.get'); + debugPrint('$e in DbColorEvent.get'); return []; } } @@ -35,7 +36,7 @@ class DbColorEvent extends TableModel { // try { // await database!.update('color_event', map); // } on Exception catch (e) { - // print('Error: ${e.toString()}'); + // debugPrint('Error: ${e.toString()}'); // } // } } diff --git a/lib/_utils/database/table/db_event.dart b/lib/_utils/database/table/db_event.dart index f08e533..3f75d51 100644 --- a/lib/_utils/database/table/db_event.dart +++ b/lib/_utils/database/table/db_event.dart @@ -1,3 +1,4 @@ +import 'package:flutter/widgets.dart'; import 'package:sqflite/sqflite.dart'; import 'table_model.dart'; @@ -26,7 +27,7 @@ class DbEvent extends TableModel { try { return await database!.query(tableName); } on Exception catch (e) { - print('$e in DbEvent.get'); + debugPrint('$e in DbEvent.get'); return []; } } @@ -37,7 +38,7 @@ class DbEvent extends TableModel { try { return await database!.insert(tableName, event); } on Exception catch (e) { - print('$e in DbEvent.insert()'); + debugPrint('$e in DbEvent.insert()'); } } @@ -47,7 +48,7 @@ class DbEvent extends TableModel { try { await database!.update(tableName, map); } on Exception catch (e) { - print('Error: ${e.toString()} in DbEvent.update()'); + debugPrint('Error: ${e.toString()} in DbEvent.update()'); } } @@ -61,7 +62,7 @@ class DbEvent extends TableModel { whereArgs: [id], ); } on Exception catch (e) { - print('Error: ${e.toString()} in DbEvent.delete()'); + debugPrint('Error: ${e.toString()} in DbEvent.delete()'); } } } diff --git a/lib/_utils/database/table/db_event_exam.dart b/lib/_utils/database/table/db_event_exam.dart index 38ca68d..a1e0308 100644 --- a/lib/_utils/database/table/db_event_exam.dart +++ b/lib/_utils/database/table/db_event_exam.dart @@ -1,3 +1,4 @@ +import 'package:flutter/widgets.dart'; import 'package:sqflite/sqflite.dart'; import 'table_model.dart'; @@ -23,7 +24,7 @@ class DbEventExam extends TableModel { 'FROM $tableName;', ); } on Exception catch (e) { - print('$e in DbEventExam.map'); + debugPrint('$e in DbEventExam.map'); return []; } } @@ -34,7 +35,7 @@ class DbEventExam extends TableModel { try { await database!.update(tableName, map); } on Exception catch (e) { - print('Error: ${e.toString()}'); + debugPrint('Error: ${e.toString()}'); } } } diff --git a/lib/_utils/database/table/db_event_schedule.dart b/lib/_utils/database/table/db_event_schedule.dart index c320234..d43e550 100644 --- a/lib/_utils/database/table/db_event_schedule.dart +++ b/lib/_utils/database/table/db_event_schedule.dart @@ -1,3 +1,4 @@ +import 'package:flutter/widgets.dart'; import 'package:sqflite/sqflite.dart'; import 'table_model.dart'; @@ -25,7 +26,7 @@ class DbEventSchedule extends TableModel { 'FROM $tableName;', ); } on Exception catch (e) { - print('$e in DbEventSchedule.map'); + debugPrint('$e in DbEventSchedule.map'); return []; } } @@ -47,7 +48,7 @@ class DbEventSchedule extends TableModel { conflictAlgorithm: ConflictAlgorithm.replace, ); } on Exception catch (e) { - print('Error: ${e.toString()}'); + debugPrint('Error: ${e.toString()}'); } } @@ -71,11 +72,11 @@ class DbEventSchedule extends TableModel { conflictAlgorithm: ConflictAlgorithm.replace, ); } on Exception catch (e) { - print('Error: ${e.toString()} in updateWithName'); + debugPrint('Error: ${e.toString()} in updateWithName'); } } } on Exception catch (e) { - print('Error: ${e.toString()} in updateWithName'); + debugPrint('Error: ${e.toString()} in updateWithName'); } } } diff --git a/lib/_utils/database/table/db_exam_schedule.dart b/lib/_utils/database/table/db_exam_schedule.dart index 44c7780..fb70b77 100644 --- a/lib/_utils/database/table/db_exam_schedule.dart +++ b/lib/_utils/database/table/db_exam_schedule.dart @@ -1,5 +1,6 @@ import 'package:app_qldt/_models/exam_schedule_model.dart'; import 'package:app_qldt/_utils/database/table/table_model.dart'; +import 'package:flutter/widgets.dart'; import 'package:sqflite/sqflite.dart'; class DbExamSchedule extends TableModel { @@ -61,7 +62,7 @@ class DbExamSchedule extends TableModel { try { await database!.delete(tableName); } on Exception catch (e) { - print('Error: ${e.toString()}'); + debugPrint('Error: ${e.toString()}'); } } } diff --git a/lib/_utils/database/table/db_notification.dart b/lib/_utils/database/table/db_notification.dart index 4d57dc5..0cf9576 100644 --- a/lib/_utils/database/table/db_notification.dart +++ b/lib/_utils/database/table/db_notification.dart @@ -1,4 +1,5 @@ import 'package:app_qldt/_models/receive_notification_model.dart'; +import 'package:flutter/widgets.dart'; import 'package:sqflite/sqflite.dart'; import 'table_model.dart'; @@ -58,10 +59,10 @@ class DbNotification extends TableModel { limit: 1, ))[0]['id_notification'] as int; - print('Last notification id: $lastId'); + debugPrint('Last notification id: $lastId'); return lastId; } on Error catch (e) { - print('$e in DbNotification.lastId'); + debugPrint('$e in DbNotification.lastId'); return null; } } @@ -76,7 +77,7 @@ class DbNotification extends TableModel { element.toMap(), ); } on Exception catch (e) { - print('$e in DbNotification.insert()'); + debugPrint('$e in DbNotification.insert()'); } } } @@ -87,7 +88,7 @@ class DbNotification extends TableModel { try { await database!.delete(tableName); } on Exception catch (e) { - print('Error: ${e.toString()}'); + debugPrint('Error: ${e.toString()}'); } } @@ -102,7 +103,7 @@ class DbNotification extends TableModel { whereArgs: [element], ); } on Exception catch (e) { - print('Error: ${e.toString()}'); + debugPrint('Error: ${e.toString()}'); } } } diff --git a/lib/_utils/database/table/db_schedule.dart b/lib/_utils/database/table/db_schedule.dart index 0a64dc6..74563ed 100644 --- a/lib/_utils/database/table/db_schedule.dart +++ b/lib/_utils/database/table/db_schedule.dart @@ -1,4 +1,5 @@ import 'package:app_qldt/_models/schedule_model.dart'; +import 'package:flutter/widgets.dart'; import 'package:sqflite/sqflite.dart'; import 'table_model.dart'; @@ -41,7 +42,7 @@ class DbSchedule extends TableModel { 'ON $tableName.id_schedule = $eventScheduleTable.id_schedule;', ); } on Exception catch (e) { - print('$e in DbSchedule.all'); + debugPrint('$e in DbSchedule.all'); return []; } } @@ -55,7 +56,7 @@ class DbSchedule extends TableModel { 'FROM $tableName;', ); } on Exception catch (e) { - print('$e in DbSchedule.moduleClass'); + debugPrint('$e in DbSchedule.moduleClass'); return []; } } @@ -70,7 +71,7 @@ class DbSchedule extends TableModel { element.toMap(), ); } on Exception catch (e) { - print('Error: ${e.toString()} in DbSchedule.insert()'); + debugPrint('Error: ${e.toString()} in DbSchedule.insert()'); } } } @@ -81,7 +82,7 @@ class DbSchedule extends TableModel { try { await database!.delete(tableName); } on Exception catch (e) { - print('Error: ${e.toString()} in DbSchedule.delete()'); + debugPrint('Error: ${e.toString()} in DbSchedule.delete()'); } } } diff --git a/lib/_utils/database/table/db_score.dart b/lib/_utils/database/table/db_score.dart index 77ef771..0d40998 100644 --- a/lib/_utils/database/table/db_score.dart +++ b/lib/_utils/database/table/db_score.dart @@ -1,4 +1,5 @@ import 'package:app_qldt/_models/score_model.dart'; +import 'package:flutter/widgets.dart'; import 'package:sqflite/sqflite.dart'; import 'table_model.dart'; @@ -65,7 +66,7 @@ class DbScore extends TableModel { try { await database!.delete(tableName); } on Exception catch (e) { - print('Error: ${e.toString()}'); + debugPrint('Error: ${e.toString()}'); } } } diff --git a/lib/_utils/database/table/db_sender.dart b/lib/_utils/database/table/db_sender.dart index 038ec49..f50fda1 100644 --- a/lib/_utils/database/table/db_sender.dart +++ b/lib/_utils/database/table/db_sender.dart @@ -1,4 +1,5 @@ import 'package:app_qldt/_models/sender_model.dart'; +import 'package:flutter/widgets.dart'; import 'package:sqflite/sqflite.dart'; import 'table_model.dart'; @@ -33,7 +34,7 @@ class DbSender extends TableModel { try { await database!.delete(tableName); } on Exception catch (e) { - print('Error: ${e.toString()}'); + debugPrint('Error: ${e.toString()}'); } } } diff --git a/lib/event_info/view/event_info_page.dart b/lib/event_info/view/event_info_page.dart index a43cdc7..4514713 100644 --- a/lib/event_info/view/event_info_page.dart +++ b/lib/event_info/view/event_info_page.dart @@ -205,6 +205,6 @@ class __TopbarState extends State<_Topbar> { } void _duplicateEvent() { - print('Duplicate event'); + debugPrint('Duplicate event'); } } diff --git a/lib/exam_schedule/bloc/exam_schedule_bloc.dart b/lib/exam_schedule/bloc/exam_schedule_bloc.dart index 9bb48f3..dcc60ac 100644 --- a/lib/exam_schedule/bloc/exam_schedule_bloc.dart +++ b/lib/exam_schedule/bloc/exam_schedule_bloc.dart @@ -71,7 +71,7 @@ class ExamScheduleBloc extends Bloc { idAccount: _userDataModel.idAccount, ), ); - print('exam_schedule_bloc.dart --- Crawl score: $scoreCrawlerStatus'); + debugPrint('exam_schedule_bloc.dart --- Crawl score: $scoreCrawlerStatus'); if (scoreCrawlerStatus.isOk) { await _userDataModel.scoreServiceController.refresh(); } @@ -82,7 +82,7 @@ class ExamScheduleBloc extends Bloc { idAccount: _userDataModel.idAccount, ), ); - print('exam_schedule_bloc.dart --- Crawl Exam Schedule: $examScheduleCrawlerStatus'); + debugPrint('exam_schedule_bloc.dart --- Crawl Exam Schedule: $examScheduleCrawlerStatus'); if (examScheduleCrawlerStatus.isOk) { canLoadNewData = true; diff --git a/lib/google_calendar_page.dart b/lib/google_calendar_page.dart index 6239e13..e5c7fab 100644 --- a/lib/google_calendar_page.dart +++ b/lib/google_calendar_page.dart @@ -36,7 +36,7 @@ class _HomeState extends State { showTitleActions: true, minTime: DateTime(2019, 3, 5), maxTime: DateTime(2200, 6, 7), onChanged: (date) { - print('change $date'); + debugPrint('change $date'); }, onConfirm: (date) { setState(() { startTime = date; @@ -58,7 +58,7 @@ class _HomeState extends State { showTitleActions: true, minTime: DateTime(2019, 3, 5), maxTime: DateTime(2200, 6, 7), onChanged: (date) { - print('change $date'); + debugPrint('change $date'); }, onConfirm: (date) { setState(() { endTime = date; diff --git a/lib/main.dart b/lib/main.dart index 572a029..06dace9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -23,7 +23,7 @@ void main() async { AppMode devMode = AppMode.debug; AppMode mode = kReleaseMode ? AppMode.release : devMode; - print('Running in mode $mode'); + debugPrint('Running in mode $mode'); runApp( Phoenix( diff --git a/lib/plan/view/local_widgets/add_guest.dart b/lib/plan/view/local_widgets/add_guest.dart index 45aa470..cf6044c 100644 --- a/lib/plan/view/local_widgets/add_guest.dart +++ b/lib/plan/view/local_widgets/add_guest.dart @@ -65,7 +65,7 @@ class ViewScheduleButton extends StatelessWidget { alignment: Alignment.centerLeft, child: OutlinedButton( onPressed: () { - // print('Xem lịch biểu'); + // debugPrint('Xem lịch biểu'); }, child: Text( 'Xem lịch biểu', diff --git a/lib/score/bloc/score_bloc.dart b/lib/score/bloc/score_bloc.dart index 8a9ea6b..af3ac26 100644 --- a/lib/score/bloc/score_bloc.dart +++ b/lib/score/bloc/score_bloc.dart @@ -104,7 +104,7 @@ class ScoreBloc extends Bloc { idAccount: _userDataModel.idAccount, ), ); - print('score_bloc.dart --- Crawl score: $scoreCrawlerStatus'); + debugPrint('score_bloc.dart --- Crawl score: $scoreCrawlerStatus'); // Also request to crawl exam schedule CrawlerStatus examScheduleCrawlerStatus = await _crawlerService.crawlExamSchedule( @@ -113,7 +113,7 @@ class ScoreBloc extends Bloc { idAccount: _userDataModel.idAccount, ), ); - print('score_bloc.dart --- Crawl exam Schedule: $examScheduleCrawlerStatus'); + debugPrint('score_bloc.dart --- Crawl exam Schedule: $examScheduleCrawlerStatus'); if (examScheduleCrawlerStatus.isOk) { await _userDataModel.examScheduleServiceController.refresh(); }