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/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/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/pubspec.yaml b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml index f5a7eb866ef9..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 @@ -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" @@ -19,4 +19,3 @@ dev_dependencies: flutter_test: sdk: flutter mockito: ^5.0.0 - pedantic: ^1.10.0 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..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 @@ -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() { @@ -122,16 +122,18 @@ 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), googleSignIn.isSignedIn: isMethodCall('isSignedIn', arguments: null), }; - tests.keys.forEach((Function f) => f()); + for (final Function f in tests.keys) { + f(); + } expect(log, tests.values); }); 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