From dd7c6d54a22eee7e61222a8c3823177debae6eda Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 16 Feb 2022 12:17:11 -0500 Subject: [PATCH 1/4] Version bump --- .../google_sign_in_platform_interface/CHANGELOG.md | 4 ++++ .../google_sign_in_platform_interface/analysis_options.yaml | 1 - .../google_sign_in_platform_interface/pubspec.yaml | 2 +- script/configs/custom_analysis.yaml | 1 - 4 files changed, 5 insertions(+), 3 deletions(-) delete mode 100644 packages/google_sign_in/google_sign_in_platform_interface/analysis_options.yaml diff --git a/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md b/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md index 928186029a48..66fdb3e72a56 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.1.2 + +* Internal code cleanup for stricter analysis options. + ## 2.1.1 * Removes dependency on `meta`. diff --git a/packages/google_sign_in/google_sign_in_platform_interface/analysis_options.yaml b/packages/google_sign_in/google_sign_in_platform_interface/analysis_options.yaml deleted file mode 100644 index 5aeb4e7c5e21..000000000000 --- a/packages/google_sign_in/google_sign_in_platform_interface/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: ../../../analysis_options_legacy.yaml diff --git a/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml index f5a7eb866ef9..e8e0722c3da9 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/google_sign_in issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.1.1 +version: 2.1.2 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/script/configs/custom_analysis.yaml b/script/configs/custom_analysis.yaml index 13a6819acd79..e31f80d123f6 100644 --- a/script/configs/custom_analysis.yaml +++ b/script/configs/custom_analysis.yaml @@ -15,7 +15,6 @@ - google_maps_flutter/google_maps_flutter_platform_interface - google_maps_flutter/google_maps_flutter_web - google_sign_in/google_sign_in -- google_sign_in/google_sign_in_platform_interface - google_sign_in/google_sign_in_web - image_picker/image_picker_platform_interface - in_app_purchase/in_app_purchase From 47448287d76fda5765229ce45d5dcb3988aa1027 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 16 Feb 2022 12:43:30 -0500 Subject: [PATCH 2/4] dart fix --- .../lib/src/method_channel_google_sign_in.dart | 2 +- .../google_sign_in_platform_interface_test.dart | 2 +- .../test/method_channel_google_sign_in_test.dart | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/method_channel_google_sign_in.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/method_channel_google_sign_in.dart index c569133a1b34..1abda09fa99f 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/method_channel_google_sign_in.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/method_channel_google_sign_in.dart @@ -55,7 +55,7 @@ class MethodChannelGoogleSignIn extends GoogleSignInPlatform { .invokeMapMethod('getTokens', { 'email': email, 'shouldRecoverAuth': shouldRecoverAuth, - }).then((result) => getTokenDataFromMap(result!)); + }).then((Map? result) => getTokenDataFromMap(result!)); } @override diff --git a/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart b/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart index a3450b6f3fb9..78e57a3eb2ac 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart'; import 'package:mockito/mockito.dart'; void main() { diff --git a/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart b/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart index fcb443f84293..12d053b8b6e4 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart @@ -9,10 +9,10 @@ import 'package:google_sign_in_platform_interface/src/types.dart'; import 'package:google_sign_in_platform_interface/src/utils.dart'; const Map kUserData = { - "email": "john.doe@gmail.com", - "id": "8162538176523816253123", - "photoUrl": "https://lh5.googleusercontent.com/photo.jpg", - "displayName": "John Doe", + 'email': 'john.doe@gmail.com', + 'id': '8162538176523816253123', + 'photoUrl': 'https://lh5.googleusercontent.com/photo.jpg', + 'displayName': 'John Doe', 'idToken': '123', 'serverAuthCode': '789', }; @@ -35,7 +35,7 @@ const Map kDefaultResponses = { }; final GoogleSignInUserData? kUser = getUserDataFromMap(kUserData); -final GoogleSignInTokenData? kToken = +final GoogleSignInTokenData kToken = getTokenDataFromMap(kTokenData as Map); void main() { @@ -131,7 +131,9 @@ void main() { googleSignIn.isSignedIn: isMethodCall('isSignedIn', arguments: null), }; - tests.keys.forEach((Function f) => f()); + for (final Function f in tests.keys) { + f(); + } expect(log, tests.values); }); From d53bc6951dab7990d737365d1ded318776d26482 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 16 Feb 2022 12:49:08 -0500 Subject: [PATCH 3/4] Manual fixes --- .../lib/src/types.dart | 24 +++++++++++++++---- .../lib/src/utils.dart | 18 +++++++------- .../method_channel_google_sign_in_test.dart | 4 ++-- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart index e30966f87598..bc50a1d2516d 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart @@ -71,13 +71,21 @@ class GoogleSignInUserData { String? serverAuthCode; @override + // TODO(stuartmorgan): Make this class immutable in the next breaking change. + // ignore: avoid_equals_and_hash_code_on_mutable_classes int get hashCode => hashObjects( [displayName, email, id, photoUrl, idToken, serverAuthCode]); @override + // TODO(stuartmorgan): Make this class immutable in the next breaking change. + // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(dynamic other) { - if (identical(this, other)) return true; - if (other is! GoogleSignInUserData) return false; + if (identical(this, other)) { + return true; + } + if (other is! GoogleSignInUserData) { + return false; + } final GoogleSignInUserData otherUserData = other; return otherUserData.displayName == displayName && otherUserData.email == email && @@ -107,12 +115,20 @@ class GoogleSignInTokenData { String? serverAuthCode; @override + // TODO(stuartmorgan): Make this class immutable in the next breaking change. + // ignore: avoid_equals_and_hash_code_on_mutable_classes int get hashCode => hash3(idToken, accessToken, serverAuthCode); @override + // TODO(stuartmorgan): Make this class immutable in the next breaking change. + // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(dynamic other) { - if (identical(this, other)) return true; - if (other is! GoogleSignInTokenData) return false; + if (identical(this, other)) { + return true; + } + if (other is! GoogleSignInTokenData) { + return false; + } final GoogleSignInTokenData otherTokenData = other; return otherTokenData.idToken == idToken && otherTokenData.accessToken == accessToken && diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/utils.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/utils.dart index 0d89835fb498..6f03a6c357fe 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/utils.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/utils.dart @@ -10,19 +10,19 @@ GoogleSignInUserData? getUserDataFromMap(Map? data) { return null; } return GoogleSignInUserData( - email: data['email']!, - id: data['id']!, - displayName: data['displayName'], - photoUrl: data['photoUrl'], - idToken: data['idToken'], - serverAuthCode: data['serverAuthCode']); + email: data['email']! as String, + id: data['id']! as String, + displayName: data['displayName'] as String?, + photoUrl: data['photoUrl'] as String?, + idToken: data['idToken'] as String?, + serverAuthCode: data['serverAuthCode'] as String?); } /// Converts token data coming from native code into the proper platform interface type. GoogleSignInTokenData getTokenDataFromMap(Map data) { return GoogleSignInTokenData( - idToken: data['idToken'], - accessToken: data['accessToken'], - serverAuthCode: data['serverAuthCode'], + idToken: data['idToken'] as String?, + accessToken: data['accessToken'] as String?, + serverAuthCode: data['serverAuthCode'] as String?, ); } diff --git a/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart b/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart index 12d053b8b6e4..a1d83c3f05e6 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart @@ -122,9 +122,9 @@ void main() { 'token': 'abc', }), () { - googleSignIn.requestScopes(['newScope', 'anotherScope']); + googleSignIn.requestScopes(['newScope', 'anotherScope']); }: isMethodCall('requestScopes', arguments: { - 'scopes': ['newScope', 'anotherScope'], + 'scopes': ['newScope', 'anotherScope'], }), googleSignIn.signOut: isMethodCall('signOut', arguments: null), googleSignIn.disconnect: isMethodCall('disconnect', arguments: null), From 4b5f85213c1a7d9c292f1c962f882874136ed088 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 16 Feb 2022 16:18:41 -0500 Subject: [PATCH 4/4] Remove pedantic --- .../google_sign_in_platform_interface/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml index e8e0722c3da9..a5bbaedd51e7 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml @@ -19,4 +19,3 @@ dev_dependencies: flutter_test: sdk: flutter mockito: ^5.0.0 - pedantic: ^1.10.0