7

I'm new to Dart/Visual studio code and have hit a wall setting up one of the predefined stagehand apps "web-angular".

I've installed the dart language support extension and created a new folder called c:\webdev\Angular_dart . From within the terminal in VSCode i ran "stagehand web-angular", then "pub get" then "pub global run webdev serve web:8888"

I'm able to see the default web page (a todo list) but when I hit F5 from within VSCode it gives me an error saying it can't see any of the files in my lib folder.

The first one it hits is..

web/main.dart:2:8: Error: Error when reading 'lib/app_component.template.dart': The system cannot find the file specified.

import 'package:Angular_Dart/app_component.template.dart' as ng;

it looks like my .packages file is setup correctly as my last line reads

Angular_Dart:lib/

And my launch.json configuration is

"name": "Dart",
"program": "web/main.dart",
"request": "launch",
"type": "dart"

Has anyone seen this?

Thanks in advance.

1
  • Try not to use uppercase in file names and package names. Angular_Dart should be angular_dart everywhere (pubspec.yaml`, imports, file names, ...) Commented Feb 28, 2019 at 20:46

2 Answers 2

5

Right now it's simple. Use following configuration:

{
    "name": "Dart",
    "program": "web/index.html",
    "request": "launch",
    "type": "dart"
}
  • VS Code: 1.50.1
  • Dart SDK: 2.11.0-213.1.beta

Make sure "program" points to the index HTML file.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this has been very helpful. Is there a way to specify hot reload?
3

Edit: This answer is out of date, see theanurin's answer above or the Dart-Code v3.7 release notes.


The Dart VS Code extension doesn't currently have first-class support for web apps so unfortunately it's not as simple as just hitting F5 like for Flutter or CLI projects.

There are some relevant discussions here:

The Flutter Devtools app is somewhat set up for this, and has VS Code tasks and launch configs to launch with webdev serve:

https://github.com/flutter/devtools/tree/master/packages/devtools/.vscode

The build config uses the Chrome Debugger for launching the browser, but has a preLaunchTask that runs webdev serve. It works, but the debugging isn't perfect, it's using source maps via the Chrome Debugger extension.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.