From d15dc88a643c4a011438bd72b23234ec40c5ba65 Mon Sep 17 00:00:00 2001 From: CoderJava Date: Tue, 29 Oct 2024 07:22:00 +0700 Subject: [PATCH 1/3] Downgrade plugin `flutter_local_notifications` ke versi 13.0.0 Didowngrade karena versi 17.1.2 tidak berfungsi di macOS. --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 060077e..9dfe644 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -99,7 +99,7 @@ dependencies: # A cross platform plugin for displaying and scheduling local notifications for Flutter applications # with the ability to customize for each platform. - flutter_local_notifications: ^17.1.2 + flutter_local_notifications: 13.0.0 # The Font Awesome Icon pack available as Flutter Icons. Provides 1600 additional icons to use # in your apps. From 0b87d05b36b5bc89bdd20c5c21001142907c8284 Mon Sep 17 00:00:00 2001 From: CoderJava Date: Tue, 29 Oct 2024 07:41:19 +0700 Subject: [PATCH 2/3] Buat function `removeTrailingSlash` didalam helper.dart Function tersebut berfungsi untuk menghapus karakter "/" diakhir dari sebuah String. --- lib/core/util/helper.dart | 4 ++++ test/util/helper_test.dart | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/core/util/helper.dart b/lib/core/util/helper.dart index 78f8d38..a9eab91 100644 --- a/lib/core/util/helper.dart +++ b/lib/core/util/helper.dart @@ -101,4 +101,8 @@ class Helper { return ConstantErrorMessage().failureUnknown; } } + + String removeTrailingSlash(String input) { + return input.replaceAll(RegExp(r'/+$'), ''); + } } diff --git a/test/util/helper_test.dart b/test/util/helper_test.dart index ec5779d..06f184c 100644 --- a/test/util/helper_test.dart +++ b/test/util/helper_test.dart @@ -170,4 +170,25 @@ void main() { expect(unknownFailure, constantErrorMessage.failureUnknown); }, ); + + test( + 'pastikan function removeTrailingSlash bisa menghapus karakter "/" diakhir dari sebuah string.', + () async { + // arrange + const input = 'https://example.com/'; + const input2 = 'https://example.com'; + const input3 = 'https://example.com////'; + const output = 'https://example.com'; + + // act + final actual1 = helper.removeTrailingSlash(input); + final actual2 = helper.removeTrailingSlash(input2); + final actual3 = helper.removeTrailingSlash(input3); + + // assert + expect(actual1, output); + expect(actual2, output); + expect(actual3, output); + }, + ); } From 7e10f16144124026d4c3acdfb24c802c82649c9d Mon Sep 17 00:00:00 2001 From: CoderJava Date: Tue, 29 Oct 2024 07:41:44 +0700 Subject: [PATCH 3/3] Hapus karakter "/" diakhir dari hostname --- .../page/setup_credential/setup_credential_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/feature/presentation/page/setup_credential/setup_credential_page.dart b/lib/feature/presentation/page/setup_credential/setup_credential_page.dart index 6fcdd8d..dd76164 100644 --- a/lib/feature/presentation/page/setup_credential/setup_credential_page.dart +++ b/lib/feature/presentation/page/setup_credential/setup_credential_page.dart @@ -148,7 +148,7 @@ class _SetupCredentialPageState extends State { ) as bool?; } if (isContinue != null && isContinue) { - final hostname = controllerHostname.text.trim(); + final hostname = helper.removeTrailingSlash(controllerHostname.text.trim()).trim(); await sharedPreferencesManager.putString(SharedPreferencesManager.keyDomainApi, hostname); helper.setDomainApiToFlavor(hostname); di.init();