dart-archive / googleapis_auth

Obtain OAuth 2.0 credentials to access Google APIs
https://pub.dev/packages/googleapis_auth
BSD 3-Clause "New" or "Revised" License
38 stars 26 forks source link

Errors when using this library #66

Closed dolanmiu closed 4 years ago

dolanmiu commented 4 years ago

When I remove this lib, these errors go away.

This is a brand new project

Can someone assist?

Thanks

Compiler message:
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/googleapis_auth-0.2.10/lib/src/oauth2_flows/implicit.dart:8:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
       ^

/C:/flutter/.pub-cache/hosted/pub.dartlang.org/googleapis_auth-0.2.10/lib/src/oauth2_flows/implicit.dart:75:23: Error: Getter not found: 'context'.
        var gapi = js.context['gapi']['auth'];
                      ^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/googleapis_auth-0.2.10/lib/src/oauth2_flows/implicit.dart:101:10: Error: Getter not found: 'document'.
    html.document.body.append(script);
         ^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/googleapis_auth-0.2.10/lib/src/oauth2_flows/implicit.dart:132:19: Error: Getter not found: 'context'.
    var gapi = js.context['gapi']['auth'];
                  ^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/googleapis_auth-0.2.10/lib/src/oauth2_flows/implicit.dart:152:14: Error: Method not found: 'JsObject'.
      new js.JsObject.jsify(json),
             ^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/googleapis_auth-0.2.10/lib/src/oauth2_flows/implicit.dart:240:44: Error: Method not found: 'ScriptElement'.
  if (nonce == null) return () => new html.ScriptElement();
                                           ^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/googleapis_auth-0.2.10/lib/src/oauth2_flows/implicit.dart:242:25: Error: Method not found: 'ScriptElement'.
  return () => new html.ScriptElement()..nonce = nonce;
                        ^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/googleapis_auth-0.2.10/lib/src/oauth2_flows/implicit.dart:248:24: Error: 'Window' isn't a type.
String _getNonce({html.Window window}) {
                       ^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/googleapis_auth-0.2.10/lib/src/oauth2_flows/implicit.dart:249:40: Error: Getter not found: 'window'.
  final currentWindow = window ?? html.window;
                                       ^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/googleapis_auth-0.2.10/lib/src/oauth2_flows/implicit.dart:253:26: Error: 'HtmlElement' isn't a type.
        (element as html.HtmlElement).nonce ?? element.attributes['nonce'];
                         ^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart:58:34: Error: 'Blob' isn't a type.
      var blob = xhr.response as Blob ?? Blob([]);
                                 ^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart:46:15: Error: The method 'HttpRequest' isn't defined for the class 'BrowserClient'.
 - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart').
Try correcting the name to the name of an existing method, or defining a method named 'HttpRequest'.
    var xhr = HttpRequest();
              ^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart:58:42: Error: The method 'Blob' isn't defined for the class 'BrowserClient'.
 - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart').
Try correcting the name to the name of an existing method, or defining a method named 'Blob'.
      var blob = xhr.response as Blob ?? Blob([]);
                                         ^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart:59:20: Error: The method 'FileReader' isn't defined for the class 'BrowserClient'.
 - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FileReader'.
      var reader = FileReader();
                   ^^^^^^^^^^

My yaml file is as follows:

name: familiar_app
description: A new Flutter project.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  rxdart: 0.23.1
  firebase_core: 0.4.4
  cloud_firestore: 0.13.0+1
  firebase_auth: 0.15.4
  cloud_functions: 0.4.1+9
  google_sign_in: 4.1.1
  googleapis_auth: 0.2.10

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages
jonasfj commented 4 years ago

Don't import package:googleapis_auth/auth_browser.dart when running in a browser context.

dolanmiu commented 4 years ago

What do I import then?

ghost commented 4 years ago

which lib you removed !!???