Home > Net >  Error: Not found: 'dart:html' import 'dart:html' as html;
Error: Not found: 'dart:html' import 'dart:html' as html;

Time:11-12

i got this weird error in my app yesterday when i try to run it and i cant quite understand how to fix it. it shows a lot of error line, this wasnt happen before and i dont know what went wrong. here's the error

Invalid depfile: D:\Kuliah\Mata Kuliah\Pemrograman Mobile\medreminder.dart_tool\flutter_build\0e1b116fd39faa66306b0a2d36ef7692\kernel_snapshot.d
Invalid depfile: D:\Kuliah\Mata Kuliah\Pemrograman Mobile\medreminder.dart_tool\flutter_build\0e1b116fd39faa66306b0a2d36ef7692\kernel_snapshot.d
/D:/Software/Flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/js-0.6.4/lib/js.dart:8:1: Error: Not found: 'dart:js'
export 'dart:js' show allowInterop, allowInteropCaptureThis;
^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/plugin_registry.dart:66:8: Error: Method not found: 'webOnlySetPluginHandler'.
ui.webOnlySetPluginHandler(handleFrameworkMessage);
^^^^^^^^^^^^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:7:7: Error: Type 'AnchorElement' not found.final AnchorElement _urlParsingNode = AnchorElement();
^^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:20:7: Error: Type 'Element' not found.
final Element? _baseElement = document.querySelector('base');
^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:7:7: Error: 'AnchorElement' isn't a type.
final AnchorElement _urlParsingNode = AnchorElement();
^^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:7:39: Error: Method not found: 'AnchorElement'.
final AnchorElement _urlParsingNode = AnchorElement();
^^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:20:7: Error: 'Element' isn't a type.
final Element? _baseElement = document.querySelector('base');
^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:20:31: Error: Undefined name 'document'.
final Element? _baseElement = document.querySelector('base');
^^^^^^^^
lib/main.dart:7:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
^
lib/Reminder/ui/home_reminder.dart:8:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
^
/D:/Software/Flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_native_timezone-2.0.0/lib/flutter_native_timezone_web.dart:2:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:13:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:6:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/utils.dart:5:8: Error: Not found: 'dart:html'
import 'dart:html';
^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:193:3: Error: Type 'html.Location' not found.
html.Location get _location => html.window.location;
^^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:195:3: Error: Type 'html.History' not found.
html.History get _history => html.window.history;
^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:198:28: Error: Type 'html.EventListener' not found.
void addPopStateListener(html.EventListener fn) {
^^^^^^^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:203:31: Error: Type 'html.EventListener' not found.
void removePopStateListener(html.EventListener fn) {
^^^^^^^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:193:39: Error: Undefined name 'window'.
html.Location get _location => html.window.location;
^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:195:37: Error: Undefined name 'window'.
html.History get history => html.window.history;
^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:198:33: Error: 'EventListener' isn't a type.
void addPopStateListener(html.EventListener fn) {
^^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:199:10: Error: Undefined name 'window'.
html.window.addEventListener('popstate', fn);
^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:203:36: Error: 'EventListener' isn't a type.
void removePopStateListener(html.EventListener fn) {
^^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart:204:10: Error: Undefined name 'window'.
html.window.removeEventListener('popstate', fn);
^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:79:48: Error: Type 'html.EventListener' not found.
external ui.VoidCallback addPopStateListener(html.EventListener fn);
^^^^^^^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:48:14: Error: Method not found: 'allowInterop'.
getPath: allowInterop(strategy.getPath),
^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:49:15: Error: Method not found: 'allowInterop'.
getState: allowInterop(strategy.getState),
^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:50:26: Error: Method not found: 'allowInterop'.
addPopStateListener: allowInterop(strategy.addPopStateListener),
^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:51:25: Error: Method not found: 'allowInterop'.
prepareExternalUrl: allowInterop(strategy.prepareExternalUrl),
^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:52:16: Error: Method not found: 'allowInterop'.
pushState: allowInterop(strategy.pushState),
^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:53:19: Error: Method not found: 'allowInterop'.
replaceState: allowInterop(strategy.replaceState),
^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:54:9: Error: Method not found: 'allowInterop'.
go: allowInterop(strategy.go),
^^^^^^^^^^^^
/D:/Software/Flutter/flutter/packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart:79:53: Error: 'EventListener' isn't a type.
external ui.VoidCallback addPopStateListener(html.EventListener fn);
^^^^^^^^^^^^^
U
nhandled exception:
FileSystemException(uri=org-dartlang-u
ntranslatable-uri:dart:html; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file
syst
em.dart:34:7)
#1 asFileUri (package:vm/kernel_front_end.dart:659:37)
#2 writeDepfile (package:vm/kernel_front_end.dart:799
:21)

#3 FrontendCompiler.compile (package:frontend_s
erver/frontend_server.dart:625:9)

#4
starter (package:frontend_server/frontend_server.dart:1451:12)

#5 main (file:///C:/b/s/w/ir/x/w/sdk/pkg/frontend_serv
er/bin/frontend_server_starter.dart:10:14)

a lot of this error have "Error: Not found: 'dart:html' import 'dart:html' as html;" i look for a way to fix it, a lot suggest to delete import dart:html in my folder, when i do that the error still the same . if anyone know how to fix this please help it would mean so much to me. thankyou

CodePudding user response:

Try running these commands:

flutter clean
flutter packages get
dart pub get

CodePudding user response:

It happens usually when you put @required in your code and dart accidentally auto includes 'dart:html' as well.

If you don't have any usage of it then try removing it, then it'll work.

CodePudding user response:

You are most likely running into the issue, that dart:html is not available on all target platforms. It should only be used for web development.

Check this answer: https://stackoverflow.com/a/70642261/1151983

  • Related