Angular 2 + Dart dependencies: Target of URI does not exist: 'package:http/browser_client.dart';

Issue

This is probably a newbie question but I cannot find the problem: I am trying to create an application with Angular 2 + Dart. This is my /pubspec.yaml file:

name: ad_checkout
description: A Dart app that uses Angular 2
version: 0.0.1
environment:
  sdk: '>=1.19.0 <2.0.0'
dependencies:
  angular2: ^2.0.0
dev_dependencies:
  browser: ^0.10.0
  dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
    platform_directives:
    - 'package:angular2/common.dart#COMMON_DIRECTIVES'
    platform_pipes:
    - 'package:angular2/common.dart#COMMON_PIPES'
    entry_points: web/main.dart
    resolved_identifiers:
      BrowserClient: 'package:http/browser_client.dart'
      Client: 'package:http/http.dart'
- dart_to_js_script_rewriter

I am working with IntelliJ IDEA and trying to follow the tutorial to enable ajax calls: https://angular.io/docs/dart/latest/tutorial/toh-pt6.html

This is my web/main.dart file:

import 'package:angular2/platform/browser.dart';
import 'package:http/browser_client.dart';

import 'package:ad_checkout/app_component.dart';

void main() {
  bootstrap(AppComponent,[
    provide(BrowserClient, useFactory: () => new BrowserClient(), deps: [])
  ]);
}

Within IntelliJ I tried “Get dependencies”, “Update dependencies” and “Clear Cache” nothing helped. What am I missing?

Solution

You do not have http listed under the dependencies: section in your pubspec.yaml.

Add http: ^0.11.3 under angular2 in your dependencies:.

Answered By – Harry Terkelsen

Answer Checked By – Katrina (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *