Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[google_sign_in] Update platform interface analysis options #4872

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.1.2

* Internal code cleanup for stricter analysis options.

## 2.1.1

* Removes dependency on `meta`.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MethodChannelGoogleSignIn extends GoogleSignInPlatform {
.invokeMapMethod<String, dynamic>('getTokens', <String, dynamic>{
'email': email,
'shouldRecoverAuth': shouldRecoverAuth,
}).then((result) => getTokenDataFromMap(result!));
}).then((Map<String, dynamic>? result) => getTokenDataFromMap(result!));
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<String?>[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 &&
Expand Down Expand Up @@ -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 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ GoogleSignInUserData? getUserDataFromMap(Map<String, dynamic>? 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<String, dynamic> 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?,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -19,4 +19,3 @@ dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.0.0
pedantic: ^1.10.0
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> kUserData = <String, String>{
"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',
};
Expand All @@ -35,7 +35,7 @@ const Map<String, dynamic> kDefaultResponses = <String, dynamic>{
};

final GoogleSignInUserData? kUser = getUserDataFromMap(kUserData);
final GoogleSignInTokenData? kToken =
final GoogleSignInTokenData kToken =
getTokenDataFromMap(kTokenData as Map<String, dynamic>);

void main() {
Expand Down Expand Up @@ -122,16 +122,18 @@ void main() {
'token': 'abc',
}),
() {
googleSignIn.requestScopes(['newScope', 'anotherScope']);
googleSignIn.requestScopes(<String>['newScope', 'anotherScope']);
}: isMethodCall('requestScopes', arguments: <String, dynamic>{
'scopes': ['newScope', 'anotherScope'],
'scopes': <String>['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);
});
Expand Down
1 change: 0 additions & 1 deletion script/configs/custom_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down