[google_sign_in] Update (web) example app. (#5634)

## Changes

**google_sign_in:**

* Updates web bootstrap following [Flutter Web initialization docs](https://docs.flutter.dev/platform-integration/web/initialization#skipping-this-step).
* Uses the recent [`web_only` library](https://pub.dev/documentation/google_sign_in_web/0.12.3/web_only/web_only-library.html) to `renderButton`.
* Updates dependencies so it can compile with `--wasm`.

(opportunistic weekend commit) **google_identity_services_web:**

* Adds missing `CredentialSelectBy.fedcm_auto` enum value.
* Bump patch version + changelog.

## Issues

* Fixes https://github.com/flutter/flutter/issues/139852
* Missing bit of https://github.com/flutter/flutter/issues/138202

## Testing

* Deployed to: https://dit-gis-test.web.app
This commit is contained in:
David Iglesias
2023-12-13 12:54:26 -08:00
committed by GitHub
parent 2133991a46
commit f455462a6b
6 changed files with 33 additions and 13 deletions

View File

@ -1,3 +1,8 @@
## 0.3.0+2
* Adds `fedcm_auto` to `CredentialSelectBy` enum.
* Adds `unknown_reason` to all `Moment*Reason` enums.
## 0.3.0+1
* Corrects 0.3.0 changelog entry about the minimum Flutter/Dart dependencies.

View File

@ -118,7 +118,10 @@ enum MomentSkippedReason {
tap_outside('tap_outside'),
/// issuing_failed
issuing_failed('issuing_failed');
issuing_failed('issuing_failed'),
/// Unknown reason
unknown_reason('unknown_reason');
///
const MomentSkippedReason(String reason) : _reason = reason;
@ -137,7 +140,10 @@ enum MomentDismissedReason {
cancel_called('cancel_called'),
/// flow_restarted
flow_restarted('flow_restarted');
flow_restarted('flow_restarted'),
/// Unknown reason
unknown_reason('unknown_reason');
///
const MomentDismissedReason(String reason) : _reason = reason;
@ -207,7 +213,10 @@ enum CredentialSelectBy {
btn_confirm_add_session('btn_confirm_add_session'),
/// A user with an existing session used the browser's "FedCM" flow.
fedcm('fedcm');
fedcm('fedcm'),
/// A fedcm authentication without user intervention.
fedcm_auto('fedcm_auto');
///
const CredentialSelectBy(String selectBy) : _selectBy = selectBy;

View File

@ -2,7 +2,7 @@ name: google_identity_services_web
description: A Dart JS-interop layer for Google Identity Services. Google's new sign-in SDK for Web that supports multiple types of credentials.
repository: https://github.com/flutter/packages/tree/main/packages/google_identity_services_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_identiy_services_web%22
version: 0.3.0+1
version: 0.3.0+2
environment:
sdk: ">=3.2.0 <4.0.0"

View File

@ -3,13 +3,11 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart';
import 'package:google_sign_in_web/google_sign_in_web.dart' as web;
import 'package:google_sign_in_web/web_only.dart' as web;
import 'stub.dart';
/// Renders a web-only SIGN IN button.
Widget buildSignInButton({HandleSignInFn? onPressed}) {
return (GoogleSignInPlatform.instance as web.GoogleSignInPlugin)
.renderButton();
return web.renderButton();
}

View File

@ -3,8 +3,8 @@ description: Example of Google Sign-In plugin.
publish_to: none
environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.10.0"
sdk: ^3.2.0
flutter: ">=3.16.0"
dependencies:
flutter:
@ -16,8 +16,7 @@ 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: ../
google_sign_in_platform_interface: ^2.4.0
google_sign_in_web: ^0.12.0
google_sign_in_web: ^0.12.3
http: ">=0.13.0 <2.0.0"
dev_dependencies:

View File

@ -7,8 +7,17 @@ found in the LICENSE file. -->
<meta charset="UTF-8">
<meta name="google-signin-client_id" content="your-client_id.apps.googleusercontent.com">
<title>Google Sign-in Example</title>
<script src="flutter.js" defer></script>
</head>
<body>
<script src="main.dart.js" type="application/javascript"></script>
<script>
window.addEventListener('load', function(ev) {
_flutter.loader.loadEntrypoint({
onEntrypointLoaded: function(engineInitializer) {
engineInitializer.autoStart();
}
});
});
</script>
</body>
</html>