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: , ); diff --git a/google_sign_in_dart/example/lib/main.dart b/google_sign_in_dart/example/lib/main.dart index 3d476480..88a98ae3 100755 --- a/google_sign_in_dart/example/lib/main.dart +++ b/google_sign_in_dart/example/lib/main.dart @@ -5,22 +5,25 @@ // ignore_for_file: public_member_api_docs import 'dart:async'; -import 'dart:convert'; +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: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 'package:googleapis_auth/googleapis_auth.dart'; +import 'package:html_unescape/html_unescape.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) { @@ -46,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() { @@ -59,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(); @@ -70,27 +73,26 @@ 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', 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; } } @@ -108,7 +110,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,16 +118,15 @@ 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'); - 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; @@ -176,7 +177,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'), ), @@ -190,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, ), @@ -213,7 +214,7 @@ class SignInDemoState extends State { if (_emailText != null) ListTile( title: Text( - _emailText, + _emailText!, maxLines: 1, overflow: TextOverflow.ellipsis, ), @@ -221,18 +222,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'), ), 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; diff --git a/google_sign_in_dart/example/pubspec.lock b/google_sign_in_dart/example/pubspec.lock index 6d2f1c3c..37b2f8e8 100644 --- a/google_sign_in_dart/example/pubspec.lock +++ b/google_sign_in_dart/example/pubspec.lock @@ -7,84 +7,84 @@ packages: name: _discoveryapis_commons url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "1.0.0" async: dependency: transitive description: 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 + dependency: "direct main" description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.2" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" + version: "1.15.0" 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: 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: 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 @@ -106,182 +106,189 @@ 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: path: ".." relative: true source: path - version: "0.0.8" + version: "0.0.9" google_sign_in_platform_interface: dependency: transitive 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.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" + version: "1.1.0" html_unescape: dependency: transitive description: name: html_unescape url: "https://pub.dartlang.org" source: hosted - version: "1.0.1+3" + version: "2.0.0" http: dependency: "direct main" description: 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" - intl: - dependency: transitive - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" + version: "4.0.0" 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: 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: 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.1" + 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: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + 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: "2.0.0" 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: "3.0.1" shared_preferences: dependency: transitive description: 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 @@ -293,98 +300,112 @@ 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: "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: 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: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" 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" diff --git a/google_sign_in_dart/example/pubspec.yaml b/google_sign_in_dart/example/pubspec.yaml index ce6fc490..74379d52 100644 --- a/google_sign_in_dart/example/pubspec.yaml +++ b/google_sign_in_dart/example/pubspec.yaml @@ -1,22 +1,27 @@ name: google_sign_in_dart_example description: Example app for google_sign_in_dart +environment: + sdk: '>=2.12.0 <3.0.0' + dependencies: flutter: sdk: flutter - http: ^0.12.2 - url_launcher: ^5.5.0 - googleapis: ^0.55.0 - extension_google_sign_in_as_googleapis_auth: ^1.0.0 + http: ^0.13.1 + url_launcher: ^6.0.3 + 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: ../ + collection: ^1.15.0-nullsafety.4 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 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..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( - '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,16 +240,16 @@ 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( - 'https://openidconnect.googleapis.com/v1/userinfo', + Uri.parse('https://openidconnect.googleapis.com/v1/userinfo'), headers: { 'Authorization': 'Bearer $token', }, ); 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( - _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 ab4e7895..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( - exchangeEndpoint, - body: json.encode({ + Uri.parse(exchangeEndpoint), + 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.lock b/google_sign_in_dart/pubspec.lock index 2c1c10a0..7052b61a 100644 --- a/google_sign_in_dart/pubspec.lock +++ b/google_sign_in_dart/pubspec.lock @@ -7,70 +7,70 @@ 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" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" + version: "1.15.0" 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: 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,161 +92,168 @@ packages: name: google_sign_in url: "https://pub.dartlang.org" source: hosted - version: "4.5.3" + 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.1+1" + version: "0.10.0" html_unescape: dependency: "direct main" description: name: html_unescape url: "https://pub.dartlang.org" source: hosted - version: "1.0.1+3" + version: "2.0.0" http: dependency: "direct main" description: 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" - intl: - dependency: transitive - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" + version: "4.0.0" 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: 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.1" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" 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: "2.0.0" 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: "3.0.1" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.10" + 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+2" + 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+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 @@ -258,98 +265,112 @@ 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: "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: "direct main" 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: 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: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" 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" diff --git a/google_sign_in_dart/pubspec.yaml b/google_sign_in_dart/pubspec.yaml index 2084ac8b..15a9eae0 100644 --- a/google_sign_in_dart/pubspec.yaml +++ b/google_sign_in_dart/pubspec.yaml @@ -1,26 +1,26 @@ 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: 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 - url_launcher: ^5.5.0 - url_launcher_macos: ^0.0.1+7 - meta: ^1.2.2 - crypto: ^2.1.5 - http: ^0.12.2 - html_unescape: ^1.0.1+3 + 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 + url_launcher: ^6.0.3 + url_launcher_macos: ^2.0.0 + meta: ^1.3.0 + crypto: ^3.0.1 + http: ^0.13.1 + html_unescape: ^2.0.0 dev_dependencies: flutter_test: