Mohamed Elrashid
Mohamed Elrashid

Reputation: 8599

Error: Not found: 'dart:html' when using googleapis_auth dart team package with flutter

When using

to access Google Api's thru Flutter using this code

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);


}

you will get this error

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

Upvotes: 2

Views: 6072

Answers (1)

Mohamed Elrashid
Mohamed Elrashid

Reputation: 8599

Base on 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.


Problem synonym and analysis :

  • Look like you are using a package

  • which depends on 'dart:html'

  • which is not supported in Flutter

Solution :

  • remove

    import 'package:googleapis_auth/auth_browser.dart';
    

Upvotes: 9

Related Questions