Error: Not found: 'dart:html' when using googleapis_auth dart team package with flutter
Solution 1
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';
Solution 2
The analyzer produces this diagnostic when an import isn’t needed because none of the names that are imported are referenced within the importing library.
The solution for now is: do not import web-only libraries in code that is supposed to run on mobile.
Common fixes: If the import isn’t needed, then remove it.
If you just want to run your flutter app on mobiles, Removing import 'package:googleapis_auth/auth_browser.dart';
in your class will fix the error.
Mohamed Elrashid
By DAY : Free Lance Ninja BY Night : I write Code :) I Read Code :) FOR FUN : : DO Hackathon , Meet people
Updated on December 09, 2022Comments
-
Mohamed Elrashid over 1 year
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;
-
Günter Zöchbauer over 5 yearsYou might be looking for stackoverflow.com/questions/48477625/…
-