Skip to content

Commit 328067e

Browse files
Rename applicationId and handle deprecation
1 parent ed838f7 commit 328067e

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

lib/oauth2.dart

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,35 @@ class LenraOauth2Helper extends OAuth2Helper {
4646
}
4747
}
4848

49-
/// Get the custom uri scheme of the app for the current plateform.
49+
const defaultApplicationId = "com.example.app";
50+
51+
/// Get the custom uri scheme of the app for the current platform.
5052
String getPlatformCustomUriScheme({
51-
String androidApplicationId = "com.example.app",
53+
@Deprecated("Use applicationId instead.") String androidApplicationId = defaultApplicationId,
54+
String applicationId = defaultApplicationId,
5255
int oauthRedirectPort = 10000,
5356
}) {
5457
// It is important to check for web first because web is also returning the TargetPlatform of the device.
5558
if (!kIsWeb) {
56-
if (defaultTargetPlatform == TargetPlatform.windows ||
57-
defaultTargetPlatform == TargetPlatform.linux) {
59+
if (defaultTargetPlatform == TargetPlatform.windows || defaultTargetPlatform == TargetPlatform.linux) {
5860
// Apparently the customUriScheme should be the full uri for Windows and Linux for oauth2_client to work properly
5961
return "http://localhost:$oauthRedirectPort";
6062
} else if (defaultTargetPlatform == TargetPlatform.android || defaultTargetPlatform == TargetPlatform.iOS) {
61-
return androidApplicationId;
63+
// If androidApplicationId has been set to something different from its default value, use it instead of applicationId. (deprecation handling)
64+
if (androidApplicationId != defaultApplicationId) {
65+
return androidApplicationId;
66+
}
67+
68+
return applicationId;
6269
}
6370
}
6471
return "http";
6572
}
6673

67-
/// Get the custom uri scheme of the app for the current plateform.
74+
/// Get the custom uri scheme of the app for the current platform.
6875
String getPlatformRedirectUri({
69-
String androidApplicationId = "com.example.app",
76+
@Deprecated("Use applicationId instead") String androidApplicationId = defaultApplicationId,
77+
String applicationId = defaultApplicationId,
7078
int oauthRedirectPort = 10000,
7179
String oauthRedirectPath = "/redirect.html",
7280
}) {
@@ -75,7 +83,12 @@ String getPlatformRedirectUri({
7583
return "${Uri.base.scheme}://${Uri.base.host}:${Uri.base.port}$oauthRedirectPath";
7684
}
7785
if (defaultTargetPlatform == TargetPlatform.android || defaultTargetPlatform == TargetPlatform.iOS) {
78-
return "$androidApplicationId://";
86+
// If androidApplicationId has been set to something different from its default value, use it instead of applicationId. (deprecation handling)
87+
if (androidApplicationId != defaultApplicationId) {
88+
return "$androidApplicationId://";
89+
}
90+
91+
return "$applicationId://";
7992
}
8093

8194
return "http://localhost:$oauthRedirectPort$oauthRedirectPath";

0 commit comments

Comments
 (0)