Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 2 additions & 7 deletions packages/google_sign_in/google_sign_in/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
## 5.0.0-nullsafety.1
## 5.0.0

* Document that the web plugin is not endorsed in the `nullsafety` prerelease for now.

## 5.0.0-nullsafety

* Migrate to nnbd.
* **Breaking change**: web plugins aren't endorsed in null-safe plugins yet.
* Migrate to null safety.

## 4.5.9

Expand Down
37 changes: 19 additions & 18 deletions packages/google_sign_in/google_sign_in/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@ class SignInDemo extends StatefulWidget {
}

class SignInDemoState extends State<SignInDemo> {
GoogleSignInAccount _currentUser;
String _contactText;
GoogleSignInAccount? _currentUser;
String? _contactText;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super optional nits: default to empty String. 😝

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


@override
void initState() {
super.initState();
_googleSignIn.onCurrentUserChanged.listen((GoogleSignInAccount account) {
_googleSignIn.onCurrentUserChanged.listen((GoogleSignInAccount? account) {
setState(() {
_currentUser = account;
});
if (_currentUser != null) {
_handleGetContact();
_handleGetContact(_currentUser!);
}
});
_googleSignIn.signInSilently();
}

Future<void> _handleGetContact() async {
Future<void> _handleGetContact(GoogleSignInAccount user) async {
setState(() {
_contactText = "Loading contact info...";
});
final http.Response response = await http.get(
'https://people.googleapis.com/v1/people/me/connections'
'?requestMask.includeField=person.names',
headers: await _currentUser.authHeaders,
Uri.parse('https://people.googleapis.com/v1/people/me/connections'
'?requestMask.includeField=person.names'),
headers: await user.authHeaders,
);
if (response.statusCode != 200) {
setState(() {
Expand All @@ -68,7 +68,7 @@ class SignInDemoState extends State<SignInDemo> {
return;
}
final Map<String, dynamic> data = json.decode(response.body);
final String namedContact = _pickFirstNamedContact(data);
final String? namedContact = _pickFirstNamedContact(data);
setState(() {
if (namedContact != null) {
_contactText = "I see you know $namedContact!";
Expand All @@ -78,14 +78,14 @@ class SignInDemoState extends State<SignInDemo> {
});
}

String _pickFirstNamedContact(Map<String, dynamic> data) {
final List<dynamic> connections = data['connections'];
final Map<String, dynamic> contact = connections?.firstWhere(
String? _pickFirstNamedContact(Map<String, dynamic> data) {
final List<dynamic>? connections = data['connections'];
final Map<String, dynamic>? contact = connections?.firstWhere(
(dynamic contact) => contact['names'] != null,
orElse: () => null,
);
if (contact != null) {
final Map<String, dynamic> name = contact['names'].firstWhere(
final Map<String, dynamic>? name = contact['names'].firstWhere(
(dynamic name) => name['displayName'] != null,
orElse: () => null,
);
Expand All @@ -107,16 +107,17 @@ class SignInDemoState extends State<SignInDemo> {
Future<void> _handleSignOut() => _googleSignIn.disconnect();

Widget _buildBody() {
if (_currentUser != null) {
GoogleSignInAccount? user = _currentUser;
if (user != null) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
ListTile(
leading: GoogleUserCircleAvatar(
identity: _currentUser,
identity: user,
),
title: Text(_currentUser.displayName ?? ''),
subtitle: Text(_currentUser.email ?? ''),
title: Text(user.displayName ?? ''),
subtitle: Text(user.email),
),
const Text("Signed in successfully."),
Text(_contactText ?? ''),
Expand All @@ -126,7 +127,7 @@ class SignInDemoState extends State<SignInDemo> {
),
ElevatedButton(
child: const Text('REFRESH'),
onPressed: _handleGetContact,
onPressed: () => _handleGetContact(user),
),
],
);
Expand Down
6 changes: 3 additions & 3 deletions packages/google_sign_in/google_sign_in/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ dependencies:
# The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version.
path: ../
http: ^0.12.0
http: ^0.13.0

dev_dependencies:
pedantic: ^1.8.0
pedantic: ^1.10.0
integration_test:
path: ../../../integration_test
flutter_driver:
Expand All @@ -24,5 +24,5 @@ flutter:
uses-material-design: true

environment:
sdk: ">=2.0.0-dev.28.0 <3.0.0"
sdk: ">=2.12.0-259.9.beta <3.0.0"
flutter: ">=1.12.13+hotfix.4"
17 changes: 9 additions & 8 deletions packages/google_sign_in/google_sign_in/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_sign_in
description: Flutter plugin for Google Sign-In, a secure authentication system
for signing in with a Google account on Android and iOS.
homepage: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in
version: 5.0.0-nullsafety.1
version: 5.0.0

flutter:
plugin:
Expand All @@ -12,25 +12,26 @@ flutter:
pluginClass: GoogleSignInPlugin
ios:
pluginClass: FLTGoogleSignInPlugin
#web:
# default_package: google_sign_in_web
web:
default_package: google_sign_in_web

dependencies:
google_sign_in_platform_interface: ^2.0.0-nullsafety
google_sign_in_platform_interface: ^2.0.0
google_sign_in_web: ^0.10.0
flutter:
sdk: flutter
meta: ^1.3.0-nullsafety.6
meta: ^1.3.0

dev_dependencies:
http: ^0.12.0
http: ^0.13.0
flutter_driver:
sdk: flutter
flutter_test:
sdk: flutter
pedantic: ^1.10.0-nullsafety.1
pedantic: ^1.10.0
integration_test:
path: ../../integration_test

environment:
sdk: ">=2.12.0-0 <3.0.0"
sdk: ">=2.12.0-259.9.beta <3.0.0"
flutter: ">=1.12.13+hotfix.5"