Flutter - Dart failing after Android Studio and Flutter update
Solution 1
EDIT: to get rid from this issue switch back to stable channel by running this command in the terminal.
flutter channel stable
run flutter upgrade
after this.
Please check detailed error by this command
flutter run --debug
Point to remember: if its not a web project then Find and remove dart:html
.
dart:html library is for web apps only (it wraps the DOM APIs) and it is not supposed run in Flutter. Please check this git issue
Solution 2
Running:
Flutter clean
and then
Flutter run --debug
Worked for me.
Solution 3
Find dart:html
in your project and remove it.
Then run flutter clean
.
In my case, for some unknown reason, at some point my IDE (VSCode) created that import in one of my files, without me noticing.
Solution 4
Remove the import 'dart:html';
statement in the file 'lib/routes/search_results_route.dart' this was added without your knowledge and is the cause of the error
Solution 5
Just by upgrading flutter the problem was solved:
flutter upgrade
codeKiller
Updated on October 12, 2021Comments
-
codeKiller over 2 years
I had a project that was running without issues and, since I updated to
Android Studio 3.5.3
andFlutter 1.13.1-pre.99 • channel master
, the same project gives a huge error when trying to run on real device.I am mentioning here Android Studio and Flutter updates because I am not sur which of them (if any) is causing the problems.
It looks to me like a problem with
flutter_web
that I installed some time ago...but still Im not sure how to uninstall flutter_web itself.NOTE: the current project is NOT a flutter web project
Here the complete error...(sorry for the huge text):
Invalid depfile: /Users/user458395/Desktop/flutterProjects/testProjectX/.dart_tool/flutter_build/0732b8ad26463ce096dc3cab1564707e/kernel_snapshot.d Invalid depfile: /Users/user458395/Desktop/flutterProjects/testProjectX/.dart_tool/flutter_build/0732b8ad26463ce096dc3cab1564707e/kernel_snapshot.d Compiler message: lib/routes/search_results_route.dart:1:8: Error: Not found: 'dart:html' import 'dart:html'; ^ ../../../Downloads/flutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/browser_client.dart:6:8: Error: Not found: 'dart:html' import 'dart:html'; ^ ../../../Downloads/flutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/browser_client.dart:97:25: Error: Type 'HttpRequest' not found. void _openHttpRequest(HttpRequest request, String method, String url, ^^^^^^^^^^^ ../../../Downloads/flutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/browser_client.dart:32:25: Error: 'HttpRequest' isn't a type. final _xhrs = new Set<HttpRequest>(); ^^^^^^^^^^^ ../../../Downloads/flutterSdk/flutter/packages/flutter/lib/src/painting/_network_image_web.dart:64:12: Error: Method not found: 'webOnlyInstantiateImageCodecFromUrl'. return ui.webOnlyInstantiateImageCodecFromUrl(resolved) as Future<ui.Codec>; // ignore: undefined_function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../../Downloads/flutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/browser_client.dart:46:19: Error: Method not found: 'HttpRequest'. var xhr = new HttpRequest(); ^^^^^^^^^^^ ../../../Downloads/flutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/browser_client.dart:57:45: Error: Method not found: 'Blob'. var blob = xhr.response == null ? new Blob([]) : xhr.response; ^^^^ ../../../Downloads/flutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/browser_client.dart:58:24: Error: Method not found: 'FileReader'. var reader = new FileReader(); ^^^^^^^^^^ ../../../Downloads/flutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/browser_client.dart:97:25: Error: 'HttpRequest' isn't a type. void _openHttpRequest(HttpRequest request, String method, String url, ^^^^^^^^^^^ Unhandled exception: FileSystemException(uri=org-dartlang-untranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs) #0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:33:7) #1 asFileUri (package:vm/kernel_front_end.dart:604:37) #2 writeDepfile (package:vm/kernel_front_end.dart:799:21) <asynchronous suspension> #3 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:472:15) <asynchronous suspension> #4 _FlutterFrontendCompiler.compile (package:flutter_frontend_server/server.dart:38:22) #5 starter (package:flutter_frontend_server/server.dart:149:27) #6 main (file:///b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:8:30) #7 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32) #8 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12) Target kernel_snapshot failed: Exception: Errors during snapshot creation: null build failed. FAILURE: Build failed with an exception. * Where: Script '/Users/user458395/Downloads/flutterSdk/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 792 * What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'. > Process 'command '/Users/user458395/Downloads/flutterSdk/flutter/bin/flutter'' finished with non-zero exit value 1 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 36s Finished with error: Gradle task assembleDebug failed with exit code 1
-
codeKiller over 4 yearshow do i get rid of flutter web??
-
codeKiller over 4 yearsstable or master? you mention master in your comment but you say stable in your answer, as you can see in my question, I am already in master
-
Ravinder Kumar over 4 yearsMy bad you need to switch back to stable by running this command into terminal
flutter channel stable
-
codeKiller over 4 yearsworking after changing to the stable channel, thanks!