From 93c4ca1b5022623c0836eba8c936d298d2a62afe Mon Sep 17 00:00:00 2001 From: JSANL <29028262+JSANL@users.noreply.github.com> Date: Wed, 27 Nov 2019 15:50:39 +0100 Subject: [PATCH 01/14] Fixed wrong assignment of _tokenExpiry to "token" --- firebase_firestore/examples/vm_example/lib/credentials.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firebase_firestore/examples/vm_example/lib/credentials.dart b/firebase_firestore/examples/vm_example/lib/credentials.dart index d68e19b8..96d57add 100644 --- a/firebase_firestore/examples/vm_example/lib/credentials.dart +++ b/firebase_firestore/examples/vm_example/lib/credentials.dart @@ -82,7 +82,7 @@ class ServiceCredential extends InternalTokenProvider { ///Fetch token from file Future> _fetch() async { if (_tokenExpiry != null && _tokenData != null) { - return {'token': _tokenExpiry, 'expiry': _tokenExpiry}; + return {'token': _tokenData, 'expiry': _tokenExpiry}; } final File file = File(tokenPath); if (file.existsSync()) { From ba63df97294fcd63c6a36115551865f5f6d5aad8 Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:04:59 -0400 Subject: [PATCH 02/14] Upgrade locked packages --- google_sign_in_dart/pubspec.lock | 126 +++++++++++++++++++------------ 1 file changed, 77 insertions(+), 49 deletions(-) diff --git a/google_sign_in_dart/pubspec.lock b/google_sign_in_dart/pubspec.lock index 2c1c10a0..b7a8aac8 100644 --- a/google_sign_in_dart/pubspec.lock +++ b/google_sign_in_dart/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.2" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.2" + version: "1.15.0" convert: dependency: transitive description: @@ -63,14 +63,21 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "5.2.1" + version: "6.1.0" flutter: dependency: "direct main" description: flutter @@ -92,7 +99,7 @@ packages: name: google_sign_in url: "https://pub.dartlang.org" source: hosted - version: "4.5.3" + version: "4.5.9" google_sign_in_platform_interface: dependency: "direct main" description: @@ -106,14 +113,14 @@ packages: name: google_sign_in_web url: "https://pub.dartlang.org" source: hosted - version: "0.9.1+1" + version: "0.9.2" html_unescape: dependency: "direct main" description: name: html_unescape url: "https://pub.dartlang.org" source: hosted - version: "1.0.1+3" + version: "1.0.2" http: dependency: "direct main" description: @@ -127,42 +134,35 @@ packages: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.3" - intl: - dependency: transitive - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" + version: "3.1.4" js: dependency: transitive description: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.1+1" + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety" + version: "0.12.10" meta: dependency: "direct main" description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.2" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety" + version: "1.8.0" path_provider_linux: dependency: transitive description: @@ -176,77 +176,91 @@ packages: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.4" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.5" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.0" + version: "1.11.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "3.0.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted - version: "3.0.13" + version: "4.2.1" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.1.5" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.10" + version: "0.5.12+4" shared_preferences_linux: dependency: "direct main" description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+2" + version: "0.0.2+4" shared_preferences_macos: dependency: "direct main" description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+10" + version: "0.0.1+11" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.4" shared_preferences_web: dependency: transitive description: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2+4" + version: "0.1.2+7" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2+3" sky_engine: dependency: transitive description: flutter @@ -258,91 +272,105 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.2" + version: "1.3.0" url_launcher: dependency: "direct main" description: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "5.5.0" + version: "5.7.10" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+1" + version: "0.0.1+4" url_launcher_macos: dependency: "direct main" description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+7" + version: "0.0.1+9" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.6" + version: "1.0.9" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.1+1" + version: "0.1.5+3" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.2" + version: "2.1.0" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" xdg_directories: dependency: transitive description: @@ -351,5 +379,5 @@ packages: source: hosted version: "0.1.2" sdks: - dart: ">=2.10.0-0.0.dev <2.10.0" - flutter: ">=1.12.13+hotfix.5 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.22.0" From b01882bf765b5764ad5e4351390151d41ec338df Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:07:41 -0400 Subject: [PATCH 03/14] Add SDK lower bound constraint to example pubspec.yaml --- google_sign_in_dart/example/pubspec.lock | 42 ++++++++++++------------ google_sign_in_dart/example/pubspec.yaml | 3 ++ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/google_sign_in_dart/example/pubspec.lock b/google_sign_in_dart/example/pubspec.lock index 6d2f1c3c..b2b833c2 100644 --- a/google_sign_in_dart/example/pubspec.lock +++ b/google_sign_in_dart/example/pubspec.lock @@ -14,42 +14,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.2" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.2" + version: "1.15.0" convert: dependency: transitive description: @@ -77,7 +77,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.2.0" file: dependency: transitive description: @@ -176,28 +176,28 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.1+1" + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.2" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety" + version: "1.8.0" path_provider_linux: dependency: transitive description: @@ -293,49 +293,49 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.2" + version: "1.3.0" url_launcher: dependency: "direct main" description: @@ -377,7 +377,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.2" + version: "2.1.0" xdg_directories: dependency: transitive description: @@ -386,5 +386,5 @@ packages: source: hosted version: "0.1.2" sdks: - dart: ">=2.10.0-0.0.dev <2.10.0" - flutter: ">=1.12.13+hotfix.5 <2.0.0" + dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.12.13+hotfix.5" diff --git a/google_sign_in_dart/example/pubspec.yaml b/google_sign_in_dart/example/pubspec.yaml index ce6fc490..a6a56899 100644 --- a/google_sign_in_dart/example/pubspec.yaml +++ b/google_sign_in_dart/example/pubspec.yaml @@ -1,6 +1,9 @@ name: google_sign_in_dart_example description: Example app for google_sign_in_dart +environment: + sdk: ">=2.8.0 <3.0.0" + dependencies: flutter: sdk: flutter From 5c5e736d52f4dd949f15a83d15f25e0d2ff792a5 Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:09:33 -0400 Subject: [PATCH 04/14] Update packages: html_unescape, meta --- google_sign_in_dart/example/pubspec.lock | 4 ++-- google_sign_in_dart/pubspec.lock | 2 +- google_sign_in_dart/pubspec.yaml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/google_sign_in_dart/example/pubspec.lock b/google_sign_in_dart/example/pubspec.lock index b2b833c2..11641012 100644 --- a/google_sign_in_dart/example/pubspec.lock +++ b/google_sign_in_dart/example/pubspec.lock @@ -148,7 +148,7 @@ packages: name: html_unescape url: "https://pub.dartlang.org" source: hosted - version: "1.0.1+3" + version: "2.0.0" http: dependency: "direct main" description: @@ -386,5 +386,5 @@ packages: source: hosted version: "0.1.2" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=1.12.13+hotfix.5" diff --git a/google_sign_in_dart/pubspec.lock b/google_sign_in_dart/pubspec.lock index b7a8aac8..05d03cbb 100644 --- a/google_sign_in_dart/pubspec.lock +++ b/google_sign_in_dart/pubspec.lock @@ -120,7 +120,7 @@ packages: name: html_unescape url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "2.0.0" http: dependency: "direct main" description: diff --git a/google_sign_in_dart/pubspec.yaml b/google_sign_in_dart/pubspec.yaml index 2084ac8b..33aa5de5 100644 --- a/google_sign_in_dart/pubspec.yaml +++ b/google_sign_in_dart/pubspec.yaml @@ -17,10 +17,10 @@ dependencies: shared_preferences_linux: ^0.0.2+2 url_launcher: ^5.5.0 url_launcher_macos: ^0.0.1+7 - meta: ^1.2.2 + meta: ^1.3.0 crypto: ^2.1.5 http: ^0.12.2 - html_unescape: ^1.0.1+3 + html_unescape: ^2.0.0 dev_dependencies: flutter_test: From 0a4e26a55595f5ddba7277d39488d84e3d0145c1 Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:10:05 -0400 Subject: [PATCH 05/14] Update packages: crypto --- google_sign_in_dart/example/pubspec.lock | 11 ++--------- google_sign_in_dart/pubspec.lock | 9 +-------- google_sign_in_dart/pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/google_sign_in_dart/example/pubspec.lock b/google_sign_in_dart/example/pubspec.lock index 11641012..24407649 100644 --- a/google_sign_in_dart/example/pubspec.lock +++ b/google_sign_in_dart/example/pubspec.lock @@ -50,20 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" extension_google_sign_in_as_googleapis_auth: dependency: "direct main" description: @@ -141,7 +134,7 @@ packages: name: googleapis_auth url: "https://pub.dartlang.org" source: hosted - version: "0.2.12" + version: "0.2.12+1" html_unescape: dependency: transitive description: diff --git a/google_sign_in_dart/pubspec.lock b/google_sign_in_dart/pubspec.lock index 05d03cbb..fc65070a 100644 --- a/google_sign_in_dart/pubspec.lock +++ b/google_sign_in_dart/pubspec.lock @@ -43,20 +43,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" crypto: dependency: "direct main" description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" fake_async: dependency: transitive description: diff --git a/google_sign_in_dart/pubspec.yaml b/google_sign_in_dart/pubspec.yaml index 33aa5de5..843515f4 100644 --- a/google_sign_in_dart/pubspec.yaml +++ b/google_sign_in_dart/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: url_launcher: ^5.5.0 url_launcher_macos: ^0.0.1+7 meta: ^1.3.0 - crypto: ^2.1.5 + crypto: ^3.0.1 http: ^0.12.2 html_unescape: ^2.0.0 From c4fec067383fd2abe954569b866e414d3ac2f64a Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:11:39 -0400 Subject: [PATCH 06/14] Update packages: shared_preferences/macos/linux --- google_sign_in_dart/example/pubspec.lock | 59 ++++++++++++++++-------- google_sign_in_dart/pubspec.lock | 20 ++++---- google_sign_in_dart/pubspec.yaml | 6 +-- 3 files changed, 53 insertions(+), 32 deletions(-) diff --git a/google_sign_in_dart/example/pubspec.lock b/google_sign_in_dart/example/pubspec.lock index 24407649..af069e32 100644 --- a/google_sign_in_dart/example/pubspec.lock +++ b/google_sign_in_dart/example/pubspec.lock @@ -71,13 +71,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "5.2.1" + version: "6.1.0" flutter: dependency: "direct main" description: flutter @@ -156,13 +163,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.3" - intl: - dependency: transitive - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" js: dependency: transitive description: @@ -197,14 +197,21 @@ packages: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+2" + version: "2.0.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.0" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" pedantic: dependency: "direct dev" description: @@ -218,7 +225,7 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "3.0.0" plugin_platform_interface: dependency: transitive description: @@ -232,7 +239,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "3.0.13" + version: "4.2.1" quiver: dependency: transitive description: @@ -246,35 +253,42 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.10" + version: "2.0.5" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+2" + version: "2.0.0" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+10" + version: "2.0.0" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2+4" + version: "2.0.0" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" sky_engine: dependency: transitive description: flutter @@ -371,13 +385,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" sdks: dart: ">=2.12.0 <3.0.0" - flutter: ">=1.12.13+hotfix.5" + flutter: ">=1.20.0" diff --git a/google_sign_in_dart/pubspec.lock b/google_sign_in_dart/pubspec.lock index fc65070a..a2b2a82b 100644 --- a/google_sign_in_dart/pubspec.lock +++ b/google_sign_in_dart/pubspec.lock @@ -162,21 +162,21 @@ packages: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+2" + version: "2.0.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.0" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.5" + version: "2.0.0" pedantic: dependency: transitive description: @@ -218,42 +218,42 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.12+4" + version: "2.0.5" shared_preferences_linux: dependency: "direct main" description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+4" + version: "2.0.0" shared_preferences_macos: dependency: "direct main" description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+11" + version: "2.0.0" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2+7" + version: "2.0.0" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+3" + version: "2.0.0" sky_engine: dependency: transitive description: flutter @@ -370,7 +370,7 @@ packages: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" sdks: dart: ">=2.12.0 <3.0.0" flutter: ">=1.22.0" diff --git a/google_sign_in_dart/pubspec.yaml b/google_sign_in_dart/pubspec.yaml index 843515f4..77bbe5a8 100644 --- a/google_sign_in_dart/pubspec.yaml +++ b/google_sign_in_dart/pubspec.yaml @@ -12,9 +12,9 @@ dependencies: sdk: flutter google_sign_in: ^4.5.3 google_sign_in_platform_interface: ^1.1.2 - shared_preferences: ^0.5.10 - shared_preferences_macos: ^0.0.1+10 - shared_preferences_linux: ^0.0.2+2 + shared_preferences: ^2.0.5 + shared_preferences_macos: ^2.0.0 + shared_preferences_linux: ^2.0.0 url_launcher: ^5.5.0 url_launcher_macos: ^0.0.1+7 meta: ^1.3.0 From f7803a4ae85fe4c9c08865932ba60ab65ec66358 Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:20:40 -0400 Subject: [PATCH 07/14] Update http and google sign in packages --- google_sign_in_dart/example/lib/main.dart | 18 +++++++------- google_sign_in_dart/example/pubspec.lock | 24 +++++++++---------- google_sign_in_dart/example/pubspec.yaml | 9 +++---- .../lib/google_sign_in_dartio.dart | 6 ++--- .../lib/src/code_exchange_sing_in.dart | 2 +- google_sign_in_dart/pubspec.lock | 12 +++++----- google_sign_in_dart/pubspec.yaml | 6 ++--- 7 files changed, 40 insertions(+), 37 deletions(-) diff --git a/google_sign_in_dart/example/lib/main.dart b/google_sign_in_dart/example/lib/main.dart index 3d476480..ef8f5409 100755 --- a/google_sign_in_dart/example/lib/main.dart +++ b/google_sign_in_dart/example/lib/main.dart @@ -9,18 +9,21 @@ import 'dart:convert'; import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart'; import 'package:flutter/foundation.dart'; +import 'package:googleapis_auth/googleapis_auth.dart'; import 'package:html_unescape/html_unescape.dart'; import 'package:flutter/material.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:google_sign_in_dartio/google_sign_in_dartio.dart'; import 'package:googleapis/gmail/v1.dart'; import 'package:googleapis/people/v1.dart'; -import 'package:googleapis_auth/auth.dart'; import 'platform_js.dart' if (dart.library.io) 'platform_io.dart'; -GoogleSignIn _googleSignIn = GoogleSignIn( - scopes: ['email', 'profile', PeopleApi.ContactsReadonlyScope]); +GoogleSignIn _googleSignIn = GoogleSignIn(scopes: [ + 'email', + 'profile', + PeopleServiceApi.contactsReadonlyScope +]); Future main() async { if (isDesktop) { @@ -70,8 +73,8 @@ class SignInDemoState extends State { Future _handleGetContact() async { setState(() => _contactText = 'Loading contact info...'); - final PeopleConnectionsResourceApi connectionsApi = - PeopleApi(_client).people.connections; + final PeopleConnectionsResource connectionsApi = + PeopleServiceApi(_client).people.connections; final ListConnectionsResponse listResult = await connectionsApi.list( 'people/me', @@ -108,7 +111,7 @@ class SignInDemoState extends State { setState(() => _emailText = 'Loading emails...'); final bool granted = await _googleSignIn - .requestScopes([GmailApi.GmailReadonlyScope]); + .requestScopes([GmailApi.gmailReadonlyScope]); if (!granted) { setState(() => _emailText = 'Gmail scope was not granted by the user.'); @@ -116,8 +119,7 @@ class SignInDemoState extends State { } _client = await _googleSignIn.authenticatedClient(); - final UsersMessagesResourceApi messagesApi = - GmailApi(_client).users.messages; + final UsersMessagesResource messagesApi = GmailApi(_client).users.messages; final ListMessagesResponse listResult = await messagesApi.list('me'); diff --git a/google_sign_in_dart/example/pubspec.lock b/google_sign_in_dart/example/pubspec.lock index af069e32..4bde80c9 100644 --- a/google_sign_in_dart/example/pubspec.lock +++ b/google_sign_in_dart/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: _discoveryapis_commons url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "1.0.0" async: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: extension_google_sign_in_as_googleapis_auth url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "2.0.2" fake_async: dependency: transitive description: @@ -106,7 +106,7 @@ packages: name: google_sign_in url: "https://pub.dartlang.org" source: hosted - version: "4.5.3" + version: "5.0.1" google_sign_in_dartio: dependency: "direct main" description: @@ -120,28 +120,28 @@ packages: name: google_sign_in_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.0.1" google_sign_in_web: dependency: transitive description: name: google_sign_in_web url: "https://pub.dartlang.org" source: hosted - version: "0.9.1+1" + version: "0.10.0" googleapis: dependency: "direct main" description: name: googleapis url: "https://pub.dartlang.org" source: hosted - version: "0.55.0" + version: "2.0.0" googleapis_auth: - dependency: transitive + dependency: "direct main" description: name: googleapis_auth url: "https://pub.dartlang.org" source: hosted - version: "0.2.12+1" + version: "1.1.0" html_unescape: dependency: transitive description: @@ -155,14 +155,14 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.2" + version: "0.13.1" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.3" + version: "4.0.0" js: dependency: transitive description: @@ -218,7 +218,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.11.0" platform: dependency: transitive description: @@ -246,7 +246,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "3.0.1" shared_preferences: dependency: transitive description: diff --git a/google_sign_in_dart/example/pubspec.yaml b/google_sign_in_dart/example/pubspec.yaml index a6a56899..384d0044 100644 --- a/google_sign_in_dart/example/pubspec.yaml +++ b/google_sign_in_dart/example/pubspec.yaml @@ -7,12 +7,13 @@ environment: dependencies: flutter: sdk: flutter - http: ^0.12.2 + http: ^0.13.1 url_launcher: ^5.5.0 - googleapis: ^0.55.0 - extension_google_sign_in_as_googleapis_auth: ^1.0.0 + googleapis: ^2.0.0 + googleapis_auth: ^1.1.0 + extension_google_sign_in_as_googleapis_auth: ^2.0.2 - google_sign_in: ^4.5.3 + google_sign_in: ^5.0.1 google_sign_in_dartio: path: ../ diff --git a/google_sign_in_dart/lib/google_sign_in_dartio.dart b/google_sign_in_dart/lib/google_sign_in_dartio.dart index 955d669f..514697c8 100644 --- a/google_sign_in_dart/lib/google_sign_in_dartio.dart +++ b/google_sign_in_dart/lib/google_sign_in_dartio.dart @@ -234,7 +234,7 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { Future _revokeToken() async { if (_haveValidToken) { await get( - 'https://oauth2.googleapis.com/revoke?token=${_tokenData.accessToken}', + Uri.parse('https://oauth2.googleapis.com/revoke?token=${_tokenData.accessToken}'), headers: { 'content-type': 'application/x-www-form-urlencoded' }, @@ -246,7 +246,7 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { if (_haveValidToken) { final String token = _tokenData.accessToken; final Response response = await get( - 'https://openidconnect.googleapis.com/v1/userinfo', + Uri.parse('https://openidconnect.googleapis.com/v1/userinfo'), headers: { 'Authorization': 'Bearer $token', }, @@ -311,7 +311,7 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { assert(_refreshToken != null); final Response response = await post( - _exchangeEndpoint, + Uri.parse(_exchangeEndpoint), body: json.encode({ 'refreshToken': _refreshToken, 'clientId': _clientId, diff --git a/google_sign_in_dart/lib/src/code_exchange_sing_in.dart b/google_sign_in_dart/lib/src/code_exchange_sing_in.dart index ab4e7895..3631697e 100644 --- a/google_sign_in_dart/lib/src/code_exchange_sing_in.dart +++ b/google_sign_in_dart/lib/src/code_exchange_sing_in.dart @@ -131,7 +131,7 @@ Future> _exchangeCode({ @required String codeVerifier, }) async { final Response response = await post( - exchangeEndpoint, + Uri.parse(exchangeEndpoint), body: json.encode({ 'code': code, 'codeVerifier': codeVerifier, diff --git a/google_sign_in_dart/pubspec.lock b/google_sign_in_dart/pubspec.lock index a2b2a82b..9a80a86f 100644 --- a/google_sign_in_dart/pubspec.lock +++ b/google_sign_in_dart/pubspec.lock @@ -92,21 +92,21 @@ packages: name: google_sign_in url: "https://pub.dartlang.org" source: hosted - version: "4.5.9" + version: "5.0.1" google_sign_in_platform_interface: dependency: "direct main" description: name: google_sign_in_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.0.1" google_sign_in_web: dependency: transitive description: name: google_sign_in_web url: "https://pub.dartlang.org" source: hosted - version: "0.9.2" + version: "0.10.0" html_unescape: dependency: "direct main" description: @@ -120,14 +120,14 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.2" + version: "0.13.1" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" + version: "4.0.0" js: dependency: transitive description: @@ -211,7 +211,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" shared_preferences: dependency: "direct main" description: diff --git a/google_sign_in_dart/pubspec.yaml b/google_sign_in_dart/pubspec.yaml index 77bbe5a8..4f0d0c69 100644 --- a/google_sign_in_dart/pubspec.yaml +++ b/google_sign_in_dart/pubspec.yaml @@ -10,8 +10,8 @@ environment: dependencies: flutter: sdk: flutter - google_sign_in: ^4.5.3 - google_sign_in_platform_interface: ^1.1.2 + google_sign_in: ^5.0.1 + google_sign_in_platform_interface: ^2.0.1 shared_preferences: ^2.0.5 shared_preferences_macos: ^2.0.0 shared_preferences_linux: ^2.0.0 @@ -19,7 +19,7 @@ dependencies: url_launcher_macos: ^0.0.1+7 meta: ^1.3.0 crypto: ^3.0.1 - http: ^0.12.2 + http: ^0.13.1 html_unescape: ^2.0.0 dev_dependencies: From 9bff537c9d51457b96146926e84f5edbfeb031af Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:21:17 -0400 Subject: [PATCH 08/14] Migrate deprecated buttons --- google_sign_in_dart/example/lib/main.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/google_sign_in_dart/example/lib/main.dart b/google_sign_in_dart/example/lib/main.dart index ef8f5409..aa009ea7 100755 --- a/google_sign_in_dart/example/lib/main.dart +++ b/google_sign_in_dart/example/lib/main.dart @@ -178,7 +178,7 @@ class SignInDemoState extends State { children: [ const Text('You are not currently signed in.'), const SizedBox(height: 16.0), - RaisedButton( + ElevatedButton( onPressed: _handleSignIn, child: const Text('SIGN IN'), ), @@ -223,18 +223,18 @@ class SignInDemoState extends State { ), ButtonBar( children: [ - FlatButton( + TextButton( onPressed: _handleSignOut, child: const Text('SIGN OUT'), ), - FlatButton( + TextButton( onPressed: () { _handleGetContact(); _handleGetEmail(); }, child: const Text('REFRESH'), ), - FlatButton( + TextButton( onPressed: _handleGetEmail, child: const Text('ADD GMAIL SCOPE'), ), From 831349abee6a2e0a9431dcea3c8465352b96c553 Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:21:35 -0400 Subject: [PATCH 09/14] Update pedantic --- google_sign_in_dart/example/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google_sign_in_dart/example/pubspec.yaml b/google_sign_in_dart/example/pubspec.yaml index 384d0044..87beba3c 100644 --- a/google_sign_in_dart/example/pubspec.yaml +++ b/google_sign_in_dart/example/pubspec.yaml @@ -20,7 +20,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.2 + pedantic: ^1.11.0 flutter: uses-material-design: true \ No newline at end of file From 7384000e2ae33483e0b40e440d55d6e434c1b83c Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:23:28 -0400 Subject: [PATCH 10/14] Optimize imports --- google_sign_in_dart/example/lib/main.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/google_sign_in_dart/example/lib/main.dart b/google_sign_in_dart/example/lib/main.dart index aa009ea7..114ed97c 100755 --- a/google_sign_in_dart/example/lib/main.dart +++ b/google_sign_in_dart/example/lib/main.dart @@ -5,17 +5,16 @@ // ignore_for_file: public_member_api_docs import 'dart:async'; -import 'dart:convert'; import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart'; import 'package:flutter/foundation.dart'; -import 'package:googleapis_auth/googleapis_auth.dart'; -import 'package:html_unescape/html_unescape.dart'; import 'package:flutter/material.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:google_sign_in_dartio/google_sign_in_dartio.dart'; import 'package:googleapis/gmail/v1.dart'; import 'package:googleapis/people/v1.dart'; +import 'package:googleapis_auth/googleapis_auth.dart'; +import 'package:html_unescape/html_unescape.dart'; import 'platform_js.dart' if (dart.library.io) 'platform_io.dart'; From 86b9a60c7a12b9a2a825d80fdb80605527a56b3f Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:29:32 -0400 Subject: [PATCH 11/14] Regen Podfile, test run on macOS --- google_sign_in_dart/example/macos/Podfile | 76 +++++-------------- .../example/macos/Podfile.lock | 24 ++---- .../macos/Runner.xcodeproj/project.pbxproj | 23 ++---- 3 files changed, 32 insertions(+), 91 deletions(-) diff --git a/google_sign_in_dart/example/macos/Podfile b/google_sign_in_dart/example/macos/Podfile index d60ec710..dade8dfa 100644 --- a/google_sign_in_dart/example/macos/Podfile +++ b/google_sign_in_dart/example/macos/Podfile @@ -9,74 +9,32 @@ project 'Runner', { 'Release' => :release, } -def parse_KV_file(file, separator='=') - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return []; +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" end - pods_ary = [] - skip_line_start_symbols = ["#", "/"] - File.foreach(file_abs_path) { |line| - next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } - plugin = line.split(pattern=separator) - if plugin.length == 2 - podname = plugin[0].strip() - path = plugin[1].strip() - podpath = File.expand_path("#{path}", file_abs_path) - pods_ary.push({:name => podname, :path => podpath}); - else - puts "Invalid plugin specification: #{line}" - end - } - return pods_ary -end -def pubspec_supports_macos(file) - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return false; + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches end - File.foreach(file_abs_path) { |line| - return true if line =~ /^\s*macos:/ - } - return false + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" end +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + target 'Runner' do use_frameworks! use_modular_headers! - # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock - # referring to absolute paths on developers' machines. - ephemeral_dir = File.join('Flutter', 'ephemeral') - symlink_dir = File.join(ephemeral_dir, '.symlinks') - symlink_plugins_dir = File.join(symlink_dir, 'plugins') - system("rm -rf #{symlink_dir}") - system("mkdir -p #{symlink_plugins_dir}") + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end - # Flutter Pods - generated_xcconfig = parse_KV_file(File.join(ephemeral_dir, 'Flutter-Generated.xcconfig')) - if generated_xcconfig.empty? - puts "Flutter-Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) end - generated_xcconfig.map { |p| - if p[:name] == 'FLUTTER_FRAMEWORK_DIR' - symlink = File.join(symlink_dir, 'flutter') - File.symlink(File.dirname(p[:path]), symlink) - pod 'FlutterMacOS', :path => File.join(symlink, File.basename(p[:path])) - end - } - - # Plugin Pods - plugin_pods = parse_KV_file('../.flutter-plugins') - plugin_pods.map { |p| - symlink = File.join(symlink_plugins_dir, p[:name]) - File.symlink(p[:path], symlink) - if pubspec_supports_macos(File.join(symlink, 'pubspec.yaml')) - pod p[:name], :path => File.join(symlink, 'macos') - end - } end - -# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. -install! 'cocoapods', :disable_input_output_paths => true diff --git a/google_sign_in_dart/example/macos/Podfile.lock b/google_sign_in_dart/example/macos/Podfile.lock index edbf2569..99cd80c4 100644 --- a/google_sign_in_dart/example/macos/Podfile.lock +++ b/google_sign_in_dart/example/macos/Podfile.lock @@ -1,38 +1,28 @@ PODS: - FlutterMacOS (1.0.0) - - shared_preferences (0.0.1) - shared_preferences_macos (0.0.1): - FlutterMacOS - - url_launcher (0.0.1) - url_launcher_macos (0.0.1): - FlutterMacOS DEPENDENCIES: - - FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`) - - shared_preferences (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences/macos`) + - FlutterMacOS (from `Flutter/ephemeral`) - shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`) - - url_launcher (from `Flutter/ephemeral/.symlinks/plugins/url_launcher/macos`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) EXTERNAL SOURCES: FlutterMacOS: - :path: Flutter/ephemeral/.symlinks/flutter/darwin-x64 - shared_preferences: - :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences/macos + :path: Flutter/ephemeral shared_preferences_macos: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos - url_launcher: - :path: Flutter/ephemeral/.symlinks/plugins/url_launcher/macos url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos SPEC CHECKSUMS: - FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9 - shared_preferences: 9fec34d1bd906196a4da48fcf6c3ad521cc00b8d - shared_preferences_macos: 5e5c2839894accb56b7d23328905b757f2bafaf6 - url_launcher: af78307ef9bafff91273b34f1c6c0c86a0004fd7 - url_launcher_macos: 76867a28e24e0b6b98bfd65f157b64108e6d477a + FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 + shared_preferences_macos: 480ce071d0666e37cef23fe6c702293a3d21799e + url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4 -PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7 +PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c -COCOAPODS: 1.9.3 +COCOAPODS: 1.10.1 diff --git a/google_sign_in_dart/example/macos/Runner.xcodeproj/project.pbxproj b/google_sign_in_dart/example/macos/Runner.xcodeproj/project.pbxproj index 1f08fe6b..084f7e54 100644 --- a/google_sign_in_dart/example/macos/Runner.xcodeproj/project.pbxproj +++ b/google_sign_in_dart/example/macos/Runner.xcodeproj/project.pbxproj @@ -26,11 +26,7 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; }; - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 70187420AD7069D6A0D6E273 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8FD10AF132D27875663768A9 /* Pods_Runner.framework */; }; - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; }; - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -50,8 +46,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */, - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */, ); name = "Bundle Framework"; runOnlyForDeploymentPostprocessing = 0; @@ -71,7 +65,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; }; 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; @@ -80,7 +73,6 @@ 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; A76B186EF93B9395FA18FCB2 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; B6AD4B4FDBD59CE2E1E55422 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -88,8 +80,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */, - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */, 70187420AD7069D6A0D6E273 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -145,8 +135,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - D73912EF22F37F9E000D13A0 /* App.framework */, - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */, ); path = Flutter; sourceTree = ""; @@ -281,7 +269,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n"; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; }; 33CC111E2044C6BF0003C045 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -330,10 +318,15 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/shared_preferences_macos/shared_preferences_macos.framework", + "${BUILT_PRODUCTS_DIR}/url_launcher_macos/url_launcher_macos.framework", ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_macos.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_macos.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; From 7f9d8b9aa4d299d28ac2d2baa196aa61bded9274 Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:32:06 -0400 Subject: [PATCH 12/14] Upgrade packages to latest resolvable null-safe versions --- google_sign_in_dart/example/pubspec.lock | 23 +++++++++++++++-------- google_sign_in_dart/example/pubspec.yaml | 2 +- google_sign_in_dart/pubspec.lock | 16 ++++++++-------- google_sign_in_dart/pubspec.yaml | 4 ++-- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/google_sign_in_dart/example/pubspec.lock b/google_sign_in_dart/example/pubspec.lock index 4bde80c9..acacf303 100644 --- a/google_sign_in_dart/example/pubspec.lock +++ b/google_sign_in_dart/example/pubspec.lock @@ -204,7 +204,7 @@ packages: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" path_provider_windows: dependency: transitive description: @@ -232,7 +232,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "2.0.0" process: dependency: transitive description: @@ -349,35 +349,42 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "5.5.0" + version: "6.0.3" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+1" + version: "2.0.0" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+7" + version: "2.0.0" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.6" + version: "2.0.2" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.1+1" + version: "2.0.0" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" vector_math: dependency: transitive description: @@ -401,4 +408,4 @@ packages: version: "0.2.0" sdks: dart: ">=2.12.0 <3.0.0" - flutter: ">=1.20.0" + flutter: ">=1.22.0" diff --git a/google_sign_in_dart/example/pubspec.yaml b/google_sign_in_dart/example/pubspec.yaml index 87beba3c..ead929ef 100644 --- a/google_sign_in_dart/example/pubspec.yaml +++ b/google_sign_in_dart/example/pubspec.yaml @@ -8,7 +8,7 @@ dependencies: flutter: sdk: flutter http: ^0.13.1 - url_launcher: ^5.5.0 + url_launcher: ^6.0.3 googleapis: ^2.0.0 googleapis_auth: ^1.1.0 extension_google_sign_in_as_googleapis_auth: ^2.0.2 diff --git a/google_sign_in_dart/pubspec.lock b/google_sign_in_dart/pubspec.lock index 9a80a86f..7052b61a 100644 --- a/google_sign_in_dart/pubspec.lock +++ b/google_sign_in_dart/pubspec.lock @@ -169,7 +169,7 @@ packages: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" path_provider_windows: dependency: transitive description: @@ -197,7 +197,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.0" process: dependency: transitive description: @@ -314,42 +314,42 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "5.7.10" + version: "6.0.3" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+4" + version: "2.0.0" url_launcher_macos: dependency: "direct main" description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+9" + version: "2.0.0" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.9" + version: "2.0.2" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.5+3" + version: "2.0.0" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+3" + version: "2.0.0" vector_math: dependency: transitive description: diff --git a/google_sign_in_dart/pubspec.yaml b/google_sign_in_dart/pubspec.yaml index 4f0d0c69..a4ae472c 100644 --- a/google_sign_in_dart/pubspec.yaml +++ b/google_sign_in_dart/pubspec.yaml @@ -15,8 +15,8 @@ dependencies: shared_preferences: ^2.0.5 shared_preferences_macos: ^2.0.0 shared_preferences_linux: ^2.0.0 - url_launcher: ^5.5.0 - url_launcher_macos: ^0.0.1+7 + url_launcher: ^6.0.3 + url_launcher_macos: ^2.0.0 meta: ^1.3.0 crypto: ^3.0.1 http: ^0.13.1 From f17333a18195ad3767fb1fe646d757dfc4ef72af Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 14:55:56 -0400 Subject: [PATCH 13/14] Migrate to null safety --- google_sign_in_dart/example/lib/main.dart | 50 +++++------ google_sign_in_dart/example/pubspec.lock | 4 +- google_sign_in_dart/example/pubspec.yaml | 3 +- .../lib/google_sign_in_dartio.dart | 86 +++++++++---------- ...ing_in.dart => code_exchange_sign_in.dart} | 47 +++++----- google_sign_in_dart/lib/src/crypto.dart | 4 +- google_sign_in_dart/lib/src/data_storage.dart | 48 +++++------ .../lib/src/token_sign_in.dart | 22 ++--- google_sign_in_dart/pubspec.yaml | 4 +- 9 files changed, 128 insertions(+), 140 deletions(-) rename google_sign_in_dart/lib/src/{code_exchange_sing_in.dart => code_exchange_sign_in.dart} (82%) diff --git a/google_sign_in_dart/example/lib/main.dart b/google_sign_in_dart/example/lib/main.dart index 114ed97c..88a98ae3 100755 --- a/google_sign_in_dart/example/lib/main.dart +++ b/google_sign_in_dart/example/lib/main.dart @@ -6,6 +6,7 @@ import 'dart:async'; +import 'package:collection/collection.dart' show IterableExtension; import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -48,11 +49,11 @@ class SignInDemo extends StatefulWidget { } class SignInDemoState extends State { - StreamSubscription sub; - AuthClient _client; - GoogleSignInAccount _currentUser; - String _contactText; - String _emailText; + late StreamSubscription sub; + AuthClient? _client; + GoogleSignInAccount? _currentUser; + String? _contactText; + String? _emailText; @override void initState() { @@ -61,7 +62,7 @@ class SignInDemoState extends State { _googleSignIn.signInSilently(); } - Future _onUserChanged(GoogleSignInAccount account) async { + Future _onUserChanged(GoogleSignInAccount? account) async { setState(() => _currentUser = account); if (_currentUser != null) { _client = await _googleSignIn.authenticatedClient(); @@ -73,26 +74,25 @@ class SignInDemoState extends State { setState(() => _contactText = 'Loading contact info...'); final PeopleConnectionsResource connectionsApi = - PeopleServiceApi(_client).people.connections; + PeopleServiceApi(_client!).people.connections; final ListConnectionsResponse listResult = await connectionsApi.list( 'people/me', requestMask_includeField: 'person.names', ); - String contact; - final List connections = listResult.connections; + String? contact; + final List? connections = listResult.connections; if (connections != null && connections.isNotEmpty) { connections.shuffle(); - final Person person = connections.firstWhere( + final Person? person = connections.firstWhereOrNull( (Person person) => - person.names.any((Name name) => name.displayName != null), - orElse: () => null, + person.names!.any((Name name) => name.displayName != null), ); if (person != null) { final Name name = - person.names.firstWhere((Name name) => name.displayName != null); + person.names!.firstWhere((Name name) => name.displayName != null); contact = name.displayName; } } @@ -118,15 +118,15 @@ class SignInDemoState extends State { } _client = await _googleSignIn.authenticatedClient(); - final UsersMessagesResource messagesApi = GmailApi(_client).users.messages; + final UsersMessagesResource messagesApi = GmailApi(_client!).users.messages; final ListMessagesResponse listResult = await messagesApi.list('me'); - String messageSnippet; - if (listResult.messages != null && listResult.messages.isNotEmpty) { - for (Message message in listResult.messages..shuffle()) { - message = await messagesApi.get('me', message.id, format: 'FULL'); - final String snippet = message.snippet; + String? messageSnippet; + if (listResult.messages != null && listResult.messages!.isNotEmpty) { + for (Message message in listResult.messages!..shuffle()) { + message = await messagesApi.get('me', message.id!, format: 'FULL'); + final String? snippet = message.snippet; if (snippet != null && snippet.trim().isNotEmpty) { messageSnippet = HtmlUnescape().convert(snippet); break; @@ -191,21 +191,21 @@ class SignInDemoState extends State { ListTile( leading: kIsWeb ? GoogleUserCircleAvatar( - identity: _currentUser, + identity: _currentUser!, ) : ClipOval( child: Image.network( - _currentUser.photoUrl ?? + _currentUser!.photoUrl ?? 'https://lh3.googleusercontent.com/a/default-user=s160-c', ), ), - title: Text(_currentUser.displayName ?? ''), - subtitle: Text(_currentUser.email ?? ''), + title: Text(_currentUser!.displayName ?? ''), + subtitle: Text(_currentUser!.email), ), if (_contactText != null) ListTile( title: Text( - _contactText, + _contactText!, maxLines: 1, overflow: TextOverflow.ellipsis, ), @@ -214,7 +214,7 @@ class SignInDemoState extends State { if (_emailText != null) ListTile( title: Text( - _emailText, + _emailText!, maxLines: 1, overflow: TextOverflow.ellipsis, ), diff --git a/google_sign_in_dart/example/pubspec.lock b/google_sign_in_dart/example/pubspec.lock index acacf303..37b2f8e8 100644 --- a/google_sign_in_dart/example/pubspec.lock +++ b/google_sign_in_dart/example/pubspec.lock @@ -44,7 +44,7 @@ packages: source: hosted version: "1.1.0" collection: - dependency: transitive + dependency: "direct main" description: name: collection url: "https://pub.dartlang.org" @@ -113,7 +113,7 @@ packages: path: ".." relative: true source: path - version: "0.0.8" + version: "0.0.9" google_sign_in_platform_interface: dependency: transitive description: diff --git a/google_sign_in_dart/example/pubspec.yaml b/google_sign_in_dart/example/pubspec.yaml index ead929ef..74379d52 100644 --- a/google_sign_in_dart/example/pubspec.yaml +++ b/google_sign_in_dart/example/pubspec.yaml @@ -2,7 +2,7 @@ name: google_sign_in_dart_example description: Example app for google_sign_in_dart environment: - sdk: ">=2.8.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: @@ -16,6 +16,7 @@ dependencies: google_sign_in: ^5.0.1 google_sign_in_dartio: path: ../ + collection: ^1.15.0-nullsafety.4 dev_dependencies: flutter_test: diff --git a/google_sign_in_dart/lib/google_sign_in_dartio.dart b/google_sign_in_dart/lib/google_sign_in_dartio.dart index 514697c8..064aad8d 100644 --- a/google_sign_in_dart/lib/google_sign_in_dartio.dart +++ b/google_sign_in_dart/lib/google_sign_in_dartio.dart @@ -13,11 +13,10 @@ import 'package:google_sign_in/google_sign_in.dart'; import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart' as platform; import 'package:http/http.dart'; -import 'package:meta/meta.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:url_launcher/url_launcher.dart'; -part 'src/code_exchange_sing_in.dart'; +part 'src/code_exchange_sign_in.dart'; part 'src/common.dart'; part 'src/crypto.dart'; part 'src/data_storage.dart'; @@ -30,14 +29,11 @@ typedef UrlPresenter = void Function(Uri uri); /// Implementation of the google_sign_in plugin in pure dart. class GoogleSignInDart extends platform.GoogleSignInPlatform { GoogleSignInDart._({ - @required DataStorage storage, - @required String clientId, - @required UrlPresenter presenter, - String exchangeEndpoint, - }) : assert(storage != null), - assert(clientId != null), - assert(presenter != null), - _storage = storage, + required DataStorage storage, + required String clientId, + required UrlPresenter presenter, + String? exchangeEndpoint, + }) : _storage = storage, _clientId = clientId, _presenter = presenter, _exchangeEndpoint = exchangeEndpoint; @@ -48,10 +44,10 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { /// the tokens is a secure, long-lived location that is accessible between /// different invocations of your application. static Future register({ - @required String clientId, - String exchangeEndpoint, - DataStorage storage, - UrlPresenter presenter, + required String clientId, + String? exchangeEndpoint, + DataStorage? storage, + UrlPresenter? presenter, }) async { presenter ??= (Uri uri) => launch(uri.toString()); @@ -79,17 +75,17 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { ); } - final String _exchangeEndpoint; + final String? _exchangeEndpoint; final String _clientId; final DataStorage _storage; UrlPresenter _presenter; - List _scopes; - String _hostedDomain; + List? _scopes; + String? _hostedDomain; - platform.GoogleSignInTokenData _tokenData; - String _refreshToken; - DateTime _expiresAt; + platform.GoogleSignInTokenData? _tokenData; + String? _refreshToken; + DateTime? _expiresAt; /// Used by the sign in flow to allow opening of a browser in a platform /// specific way. @@ -99,16 +95,15 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { UrlPresenter get presenter => _presenter; set presenter(UrlPresenter value) { - assert(value != null); _presenter = value; } @override Future init({ - @required String hostedDomain, + String? hostedDomain, List scopes = const [], platform.SignInOption signInOption = platform.SignInOption.standard, - String clientId, + String? clientId, }) async { assert(clientId == null || clientId == _clientId, 'ClientID ($clientId) does not match the one used to register the plugin $_clientId.'); @@ -118,7 +113,7 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { 'Check https://developers.google.com/identity/protocols/googlescopes ' 'for a list of valid OAuth 2.0 scopes.'); - if (scopes == null || scopes.isEmpty) { + if (scopes.isEmpty) { _scopes = const ['openid', 'email', 'profile']; } else { _scopes = scopes; @@ -128,7 +123,7 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { } @override - Future signInSilently() async { + Future signInSilently() async { if (_haveValidToken) { return _storage.userData; } else if (_refreshToken != null) { @@ -145,9 +140,9 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { } @override - Future signIn() async { + Future signIn() async { if (_haveValidToken) { - final platform.GoogleSignInUserData userData = _storage.userData; + final platform.GoogleSignInUserData? userData = _storage.userData; if (userData == null) { await _fetchUserProfile(); } @@ -160,21 +155,21 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { @override Future getTokens( - {String email, bool shouldRecoverAuth}) async { + {required String email, bool? shouldRecoverAuth}) async { if (_haveValidToken) { - return _tokenData; + return _tokenData!; } else if (_refreshToken != null) { // if refreshing the token fails, and shouldRecoverAuth is true, then we // will prompt the user to login again try { await _doTokenRefresh(); - return _tokenData; + return _tokenData!; } catch (_) {} } - if (shouldRecoverAuth) { + if (shouldRecoverAuth!) { await _performSignIn(_scopes); - return _tokenData; + return _tokenData!; } else { throw PlatformException( code: GoogleSignInAccount.kUserRecoverableAuthError); @@ -209,7 +204,7 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { } @override - Future clearAuthCache({String token}) async { + Future clearAuthCache({String? token}) async { await _revokeToken(); _storage.clear(); _initFromStore(); @@ -234,7 +229,8 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { Future _revokeToken() async { if (_haveValidToken) { await get( - Uri.parse('https://oauth2.googleapis.com/revoke?token=${_tokenData.accessToken}'), + Uri.parse( + 'https://oauth2.googleapis.com/revoke?token=${_tokenData!.accessToken}'), headers: { 'content-type': 'application/x-www-form-urlencoded' }, @@ -244,7 +240,7 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { Future _fetchUserProfile() async { if (_haveValidToken) { - final String token = _tokenData.accessToken; + final String? token = _tokenData!.accessToken; final Response response = await get( Uri.parse('https://openidconnect.googleapis.com/v1/userinfo'), headers: { @@ -253,7 +249,7 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { ); if (response.statusCode > 300) { - if (response.statusCode == 401){ + if (response.statusCode == 401) { await signOut(); } throw PlatformException( @@ -268,23 +264,23 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { } bool get _haveValidToken { - return _expiresAt != null && DateTime.now().isBefore(_expiresAt); + return _expiresAt != null && DateTime.now().isBefore(_expiresAt!); } - Future _performSignIn(List scopes) async { + Future _performSignIn(List? scopes) async { Future> future; if (_exchangeEndpoint != null) { future = _codeExchangeSignIn( - scope: scopes.join(' '), + scope: scopes!.join(' '), clientId: _clientId, hostedDomains: _hostedDomain, presenter: presenter, - exchangeEndpoint: _exchangeEndpoint, + exchangeEndpoint: _exchangeEndpoint!, uid: _storage.id, ); } else { future = _tokenSignIn( - scope: scopes.join(' '), + scope: scopes!.join(' '), clientId: _clientId, hostedDomains: _hostedDomain, presenter: presenter, @@ -306,13 +302,13 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { await _fetchUserProfile(); } - Future _doTokenRefresh() async { + Future> _doTokenRefresh() async { assert(_exchangeEndpoint != null); assert(_refreshToken != null); final Response response = await post( - Uri.parse(_exchangeEndpoint), - body: json.encode({ + Uri.parse(_exchangeEndpoint!), + body: json.encode({ 'refreshToken': _refreshToken, 'clientId': _clientId, }), @@ -327,6 +323,8 @@ class GoogleSignInDart extends platform.GoogleSignInPlatform { } else { return Future>.error(response.body); } + + throw Exception('Error refreshing token'); } void _initFromStore() { diff --git a/google_sign_in_dart/lib/src/code_exchange_sing_in.dart b/google_sign_in_dart/lib/src/code_exchange_sign_in.dart similarity index 82% rename from google_sign_in_dart/lib/src/code_exchange_sing_in.dart rename to google_sign_in_dart/lib/src/code_exchange_sign_in.dart index 3631697e..ffdd74cd 100644 --- a/google_sign_in_dart/lib/src/code_exchange_sing_in.dart +++ b/google_sign_in_dart/lib/src/code_exchange_sign_in.dart @@ -10,18 +10,13 @@ part of '../google_sign_in_dartio.dart'; /// Once the auth code comes back it make a post to [exchangeEndpoint] for /// to obtain the access and refresh tokens. Future> _codeExchangeSignIn({ - @required String clientId, - @required String exchangeEndpoint, - @required String scope, - @required UrlPresenter presenter, - String hostedDomains, - String uid, + required String clientId, + required String exchangeEndpoint, + required String scope, + required UrlPresenter presenter, + String? hostedDomains, + String? uid, }) async { - assert(clientId != null); - assert(exchangeEndpoint != null); - assert(presenter != null); - assert(scope != null); - final Completer> completer = Completer>(); @@ -84,18 +79,18 @@ Future> _codeExchangeSignIn({ } Future> _validateAndExchangeCodeResponse({ - @required HttpRequest request, - @required String state, - @required String exchangeEndpoint, - @required String redirectUrl, - @required String clientId, - @required String codeVerifier, + required HttpRequest request, + required String state, + required String exchangeEndpoint, + required String redirectUrl, + required String clientId, + required String codeVerifier, }) { final Map authResponse = request.requestedUri.queryParameters; - final String returnedState = authResponse['state']; - final String code = authResponse['code']; + final String? returnedState = authResponse['state']; + final String? code = authResponse['code']; - String message; + String? message; if (state != returnedState) { message = 'Invalid response from server (state did not match).'; } @@ -124,15 +119,15 @@ Future> _validateAndExchangeCodeResponse({ } Future> _exchangeCode({ - @required String exchangeEndpoint, - @required String redirectUrl, - @required String clientId, - @required String code, - @required String codeVerifier, + required String exchangeEndpoint, + required String redirectUrl, + required String clientId, + required String? code, + required String codeVerifier, }) async { final Response response = await post( Uri.parse(exchangeEndpoint), - body: json.encode({ + body: json.encode({ 'code': code, 'codeVerifier': codeVerifier, 'clientId': clientId, diff --git a/google_sign_in_dart/lib/src/crypto.dart b/google_sign_in_dart/lib/src/crypto.dart index a1c2396c..a7b6c1ad 100644 --- a/google_sign_in_dart/lib/src/crypto.dart +++ b/google_sign_in_dart/lib/src/crypto.dart @@ -13,10 +13,8 @@ const String _charset = /// See "Proof Key for Code Exchange by OAuth Public Clients (RFC 7636) /// " String _generateSecureRandomString( - [Random entropySource, int entropyBytes = 64]) { + [Random? entropySource, int entropyBytes = 64]) { entropySource ??= Random.secure(); - assert(entropySource != null, 'entropySource cannot be null'); - assert(entropyBytes != null, 'entropyBytes cannot be null'); final StringBuffer buffer = StringBuffer(); int remainingLength = entropyBytes; diff --git a/google_sign_in_dart/lib/src/data_storage.dart b/google_sign_in_dart/lib/src/data_storage.dart index b9204275..186c5c03 100644 --- a/google_sign_in_dart/lib/src/data_storage.dart +++ b/google_sign_in_dart/lib/src/data_storage.dart @@ -7,10 +7,8 @@ part of '../google_sign_in_dartio.dart'; /// Helper class for persisting tokens between sessions class DataStorage { /// Create an instance that will persist the values using [store]. - const DataStorage._({@required Store store, @required String clientId}) - : assert(store != null), - assert(clientId != null), - _store = store, + const DataStorage._({required Store store, required String clientId}) + : _store = store, _clientId = clientId; final Store _store; @@ -31,27 +29,27 @@ class DataStorage { /// In case there is no user logged in this value is the id of the last user /// that was logged in. This id can be used as a hint when the user tries to /// login again. - String get id => _store.get(_getKey(_kIdKey)); + String? get id => _store.get(_getKey(_kIdKey)); /// Saves the JSON Web Token (JWT) that contains digitally signed identity /// information about the user. - String get idToken => _store.get(_getKey(_kIdTokenKey)); + String? get idToken => _store.get(_getKey(_kIdTokenKey)); - set idToken(String value) => _setValue(_kIdTokenKey, value); + set idToken(String? value) => _setValue(_kIdTokenKey, value); /// Saves the token that your application sends to authorize a Google API /// request. - String get accessToken => _store.get(_getKey(_kAccessTokenKey)); + String? get accessToken => _store.get(_getKey(_kAccessTokenKey)); - set accessToken(String value) => _setValue(_kAccessTokenKey, value); + set accessToken(String? value) => _setValue(_kAccessTokenKey, value); /// Saves the remaining lifetime of the access token. - DateTime get expiresAt { - final String date = _store.get(_getKey(_kExpirationAtKey)); + DateTime? get expiresAt { + final String? date = _store.get(_getKey(_kExpirationAtKey)); return date != null ? DateTime.parse(date) : null; } - set expiresAt(DateTime value) { + set expiresAt(DateTime? value) { _setValue(_kExpirationAtKey, value?.toIso8601String()); } @@ -60,18 +58,20 @@ class DataStorage { /// Refresh tokens are present if you provided a /// [GoogleSignInDart._exchangeEndpoint] value and are valid until the /// user revokes access. - String get refreshToken => _store.get(_getKey(_kRefreshTokenKey)); + String? get refreshToken => _store.get(_getKey(_kRefreshTokenKey)); - set refreshToken(String value) => _setValue(_kRefreshTokenKey, value); + set refreshToken(String? value) => _setValue(_kRefreshTokenKey, value); /// Retrieve the authentication data after sign in. platform.GoogleSignInTokenData get tokenData { if (idToken != null || accessToken != null) { return platform.GoogleSignInTokenData( - idToken: idToken, accessToken: accessToken); + idToken: idToken, + accessToken: accessToken, + ); } - return null; + return platform.GoogleSignInTokenData(); } set tokenData(platform.GoogleSignInTokenData data) { @@ -83,7 +83,7 @@ class DataStorage { /// /// Returns an empty list if no authorization has take place yet. List get scopes { - final String value = _store.get(_getKey(_kScopeKey)); + final String? value = _store.get(_getKey(_kScopeKey)); if (value == null || value.isEmpty) { return []; } @@ -136,12 +136,12 @@ class DataStorage { } /// Retrieve information about this signed in user based on the id_token. - platform.GoogleSignInUserData get userData { + platform.GoogleSignInUserData? get userData { if (idToken != null) { return platform.GoogleSignInUserData( - id: _store.get(_getKey(_kIdKey)), + id: _store.get(_getKey(_kIdKey))!, displayName: _store.get(_getKey(_kNameKey)), - email: _store.get(_getKey(_kEmailKey)), + email: _store.get(_getKey(_kEmailKey))!, photoUrl: _store.get(_getKey(_kPictureKey)), idToken: idToken, ); @@ -150,7 +150,7 @@ class DataStorage { return null; } - void _setValue(String key, String value) { + void _setValue(String key, String? value) { if (value == null) { _store.remove(_getKey(key)); } else { @@ -170,7 +170,7 @@ abstract class Store { void remove(String key); /// Get the value at specified [key] or nul if it doesn't exists. - String get(String key); + String? get(String key); /// Remove all the values store. void clearAll(); @@ -182,8 +182,8 @@ class _SharedPreferencesStore extends Store { final SharedPreferences _preferences; @override - String get(String key) { - return _preferences.get(key); + String? get(String key) { + return _preferences.get(key) as String?; } @override diff --git a/google_sign_in_dart/lib/src/token_sign_in.dart b/google_sign_in_dart/lib/src/token_sign_in.dart index cc27d491..eb52a182 100644 --- a/google_sign_in_dart/lib/src/token_sign_in.dart +++ b/google_sign_in_dart/lib/src/token_sign_in.dart @@ -10,16 +10,12 @@ part of '../google_sign_in_dartio.dart'; /// Using this implementation will not provide a refresh token, that means that /// the user will need to login again after the access token expires (~1 hour) Future> _tokenSignIn({ - @required String clientId, - @required String scope, - @required UrlPresenter presenter, - String hostedDomains, - String uid, + required String clientId, + required String scope, + required UrlPresenter presenter, + String? hostedDomains, + String? uid, }) async { - assert(presenter != null); - assert(clientId != null); - assert(scope != null); - final Completer> completer = Completer>(); @@ -76,11 +72,11 @@ Future> _tokenSignIn({ Future> _validateTokenResponse( HttpRequest request, String state) async { final Map authResponse = request.requestedUri.queryParameters; - final String returnedState = authResponse['state']; - final String accessToken = authResponse['access_token']; - final String idToken = authResponse['id_token']; + final String? returnedState = authResponse['state']; + final String? accessToken = authResponse['access_token']; + final String? idToken = authResponse['id_token']; - String message; + String? message; if (state != returnedState) { message = 'Invalid response from server (state did not match).'; } diff --git a/google_sign_in_dart/pubspec.yaml b/google_sign_in_dart/pubspec.yaml index a4ae472c..15a9eae0 100644 --- a/google_sign_in_dart/pubspec.yaml +++ b/google_sign_in_dart/pubspec.yaml @@ -1,11 +1,11 @@ name: google_sign_in_dartio description: Flutter package for Google Sign-In built in dart and support both Mobile and Desktop environments. -version: 0.0.8 +version: 0.0.9 homepage: https://github.com/fluttercommunity/firebase_dart_sdk/tree/develop/google_sign_in_dart commit: 89794a635a5efad6705e3d7ccc29e8139318d947 environment: - sdk: ">=2.8.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: From 14c106855590ab3dc8300b30ccd9e697d8571365 Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Sat, 10 Apr 2021 15:24:33 -0400 Subject: [PATCH 14/14] Update README.md --- google_sign_in_dart/README.md | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/google_sign_in_dart/README.md b/google_sign_in_dart/README.md index c8e9a8db..97174772 100644 --- a/google_sign_in_dart/README.md +++ b/google_sign_in_dart/README.md @@ -17,24 +17,19 @@ mainly used on Desktop. 1. Run `flutter pub get` 1. Import ```dart - import 'package:google_sign_in/google_sign_in.dart'; import 'package:google_sign_in_dartio/google_sign_in_dartio.dart'; ``` 1. Register the package - ```dart - import 'package:flutter/material.dart'; - import 'package:google_sign_in/google_sign_in.dart'; - import 'package:google_sign_in_dartio/google_sign_in_dartio.dart'; - - void main() { + ```dart + Future main() async { if (isDesktop) { - GoogleSignInPlatform.register(clientId: ); + await GoogleSignInDart.register(clientId: ); } runApp(MyApp()); } ``` - Note: You might want to `await` for the `register` method to finish before calling any `GoogleSignIn` methods when your app starts. + Note: You should ensure the `register` method completes before calling any `GoogleSignIn` methods when your app starts. ### Usage You can use the normal `GoogleSignIn` methods. @@ -54,12 +49,11 @@ keep the user logged in, you need to deploy a oAuth code exchange endpoint. Once the package like this. import 'package:flutter/material.dart'; - import 'package:google_sign_in/google_sign_in.dart'; import 'package:google_sign_in_dartio/google_sign_in_dartio.dart'; - void main() { + Future main() async { if (isDesktop) { - GoogleSignInPlatform.register( + await GoogleSignInDart.register( clientId: , exchangeEndpoint: , );