Reputation: 56864
My Dart app project structure:
myapp/
pubspec.yaml
pubspec.lock
asset/
...assets
build/
packages/
web/
lookups/
AjaxLookups.dart
requests/
RESTClient.dart
AjaxRESTClient.dart
The AjaxLookups file:
library myapp;
abstract class AjaxLookups {
static final String BASE_URL = "/myapp";
static final String DO_S0METHING_SERVICE_URL = BASE_URL + "/doSomething";
}
The RESTClient file:
library myapp;
typedef void Callback(String json);
abstract class RESTClient {
void get(String url, Callback onFail, Callback onSuccess);
void post(String url, String dataJSON, Callback onFail, Callback onSuccess);
}
The AjaxRESTClient file:
library myapp;
import "RESTClient.dart";
import "../lookups/AjaxLookups.dart";
import "dart:html";
import "dart:convert" show JSON;
class AjaxRESTClient implements RESTClient, AjaxLookups {
// ...
}
Above, the import statement for AjaxLookups
is causing a compiler error:
Target of URI does not exist: '../request/AjaxLookups.dart'
Why am I getting this? Why can't Dart find ../request/AjaxLookups.dart
? What do I need to do to fix it?
Upvotes: 0
Views: 2081
Reputation: 56864
I figured it out. I was declaring a new myapp
library inside each source file. Instead I added a main/driver Dart file, declared a library in it called myapp
, and then changed all the other source files to be part of myapp;
.
Upvotes: 0
Reputation: 2325
It looks like the file AjaxLookups.dart is in the lookups folder, so your import should be:
import "../lookups/AjaxLookups.dart";
Upvotes: 1