Dart aqueduct Error: Not found: 'dart:html' - dart

I have been using aqueduct for a simple server that if it gets HTTP request, analyze it, and send an HTTP request to other apps. However, whenever I tried to import dart:HTML, it gives an error.
-- Aqueduct CLI Version: 3.3.0+1
-- Aqueduct project version: 3.3.0+1
-- Preparing...
*** Uncaught error
IsolateSpawnException: Unable to spawn isolate: lib/controller/test_controller.dart:5:8: Error: Not found: 'dart:html'
import 'dart:html';
^
**** Stacktrace
****
I searched for answer on google, and i found that android sdk is not able to use dart:HTML. So i tried with
stagehand web-simple
webdev serve
to find out if installed sdk is able to use dart:HTML or not and it worked.
Is there any way that I could download dart web libraries(dart:HTML) on aqueduct? If it is not possible, is there any other way that I could perform these actions?

Related

How to use msw (mocking service worker) with React typescript?

I have installed msw using package.json entry in my react typescript project. And appropriately invoking msw worker start but I constantly get the error
**getWorkerInstance.ts:85 Uncaught (in promise) Error: [MSW] Failed to register the Service Worker:
Failed to register a ServiceWorker for scope ('http://localhost:3000/') with script ('http://localhost:3000/mockServiceWorker.js'): The script has an unsupported MIME type ('text/html').
at getWorkerInstance (getWorkerInstance.ts:85:1) at async startWorkerInstance (createStartHandler.ts:31:1) at async SetupWorkerApi.start (setupWorker.ts:188:1)***
**
Can anyone provide an example source code of how msw works with react typescript ? I got a native react project but that worked? Is msw not supported with React typescript?
Can anyone provide an example source code of how msw works with react typescript ? I got a native react project but that worked? Is msw not supported with React typescript?

Failed to start the Dart CLI isolate. Could not resolve DartDev snapshot or kernel. (null)

I have some error while trying to run dart file, saying
Failed to start the Dart CLI isolate. Could not resolve DartDev snapshot or kernel.
(null).
NOTE: iam not installing flutter
The problem is in my dart SDK, the SDK was corrupt and to solve this issue just delete last installed SDK and install new one.

Unable to launch web project through dart editor

Just starting up on Dart and I am unable to launch web project from dart editor, command line projects work fine.
I get this exception while trying to start web project
Running pub get on C:\Users\Admin\dart\DartABWebApp ... ---
Pub get failed, [69] Resolving dependencies...
Got socket error trying to find package browser at https://pub.dartlang.org.
Anyone knows how to resolve this ?
I moved the installation directly under primary drive and that did the trick

Dart2JS Cannot Find Import Packages WebStorm

I am using the WebStorm 8 IDE to build a dart web app. I have the following directory structure:
root
web
main.dart
lib
packages
browser
intl
intl.dart
pubspec.lock
pubspec.yaml
In main.dart I have the following import statment: import "package:intl/intl.dart";
However when I try and compile main.dart to javascript I get the following error:
dart2js
Error occurred:
/Path/To/Project/root/web/main.dart:2:8:
Error: Can't read 'package:intl/intl.dart' (Error reading '/Path/To/Project/root/web/packages/intl/intl.dart' (OS Error: No such file or directory, errno = 2)).
import "package:../packages/intl/intl.dart";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Compilation failed.
So it seems that dart2js looks in the current directory of the dart file to be converted for the packages, which is incorrect.
I tried changing my import statement to import "package:../packages/intl/intl.dart"; but I got the same error.
Does anyone have any ideas?
UPDATE:
I can use pub build to build my project and produce a main.dart.js. Not sure what is different when I call build, perhaps something is wrong with WebStorm?
dart2js is not a recommended workflow and can be buggy in WebStorm 8. It is completely removed from the context menu in the upcoming WebStorm 9. Use 'pub build'.
I can't see anything wrong. I think this is one of the cases where only
pub cache repair
can help.

fileSystem.chooseEntry from package:chrome/app.dart generates runtime error

Has anyone successfully used any fileSystem calls in package:chrome/app.dart? (This is the Chrome API package for Google Dart.)
Here's my code:
import 'package:chrome/app.dart';
void main() {
fileSystem.chooseEntry();
}
Here's my pubspec.yaml file:
name: ChooseEntry
description: A sample chrome packaged application
dependencies:
browser: any
chrome: any
meta: any
The other files were generated automatically by the Dart Editor and remain untouched by me.
The error I get from Dartium is:
Breaking on exception: 'package:chrome/src/common.dart': malformed type: line 72 pos 29: type 'js.Callback' is not loaded
When I compile to JS and run in Dartium or Chrome, I get this error:
Uncaught RuntimeError: Error: Cannot resolve 'Callback'.
So, my question is whether anyone has successfully used the chooseEntry API, or any API in fileSystem and, if so, what about what I did needs to be fixed. My guess is that I'm missing a package, but I can't identify what it might be.
I did add package "js" to pubspec.yaml, with no effect. I also tried making copies of all the packages, in case Dartium or Chrome didn't handle the symlinks correctly, and that didn't help either. (I doubt that that's the problem, as it found the code for fileSystem.chooseEntry just fine.)
I'm using:
Dart Editor version 1.0.0_r30798 (STABLE)
Dart SDK version 1.0.0.10_r30798
The chrome package appears not to be maintained anymore, consider using chrome_gen instead by replacing chrome with chrome_gen in pubspec.yaml and by editing the import statement like this:
import 'package:chrome_gen/chrome_app.dart';
main() {
fileSystem.chooseEntry();
}
The difference between these two packages is that wrappers are hand-written in chrome and autogenerated in chrome_gen from the json and idl files from Chrome.
Links:
Pub Package: chrome_gen
Mailing List: What is the difference between chrome and chrome_gen ?

Resources