jjzjj

google-api - 错误 : Not found: 'dart:html' when using googleapis_auth dart team package with flutter

coder 2023-07-22 原文

使用时

使用此代码通过 Flutter 访问 Google Api

import 'dart:convert';
import 'dart:io';

import 'package:googleapis_auth/auth.dart';
import 'package:googleapis_auth/auth_browser.dart';
import 'package:googleapis_auth/auth_io.dart';
import 'package:googleapis/androidpublisher/v3.dart';

Future main() async {
  dynamic jsonData = json.decode(
      await File('api-xxxxxxxxxxxxxxxxxxxx.json')
          .readAsString());
  var scopes = [AndroidpublisherApi.AndroidpublisherScope];
  final accountCredentials = new ServiceAccountCredentials.fromJson(jsonData);

  AuthClient client = await clientViaServiceAccount(accountCredentials, scopes);


}

你会得到这个错误

Error: Not found: 'dart:html' import 'dart:html' as html;

最佳答案

基于FAQ - Flutter :

Can Flutter run any Dart code?

Flutter should be able to run most Dart code that does not import (transitively, or directly) dart:mirrors or dart:html.


问题同义词及解析:

  • 看起来你正在使用一个包

  • 这取决于 'dart:html'

  • Flutter 不支持

解决方案:

  • 移除

    import 'package:googleapis_auth/auth_browser.dart';
    

关于google-api - 错误 : Not found: 'dart:html' when using googleapis_auth dart team package with flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54321978/

有关google-api - 错误 : Not found: 'dart:html' when using googleapis_auth dart team package with flutter的更多相关文章

随机推荐