1

I have a web app using polymer (not sure if the polymer aspect is relevant), and I'm trying to spawn an isolate from an external package. While I can import the package fine, using the same path in Uri.file results in an invalid uri. For example:

//packaged_app.dart library packaged_app;

main(args, message){
  //do something
}

//main_app.dart
library main_app.dart;
import 'package:polymer/polymer.dart';
import 'dart:isolate';
//import 'package:packaged_app/packaged_app.dart'; (finds the correct file, but not needed)

void main(){
  initPolymer();
  var uri = new Uri.file('package:packaged_app/packaged_app.dart');
  var rp = new ReceivePort();
  Isolate.spawnUri(uri, rp.sendPort);
}

I've tried many variations on the uri, including:

- new Uri.file(path), and - new Uri(path: path)

with values of path including:

- package:packaged_app/packaged_app.dart, - packages/packaged_app/packaged_app.dart, - ../relative/path/to/packaged_app/packaged_app.dart, and - /absolute/path/to/packaged_app/packaged_app.dart

all to not avail. If I copy packaged_app.dart into the same directory as main_app.dart it runs fine, but that feels dirty.

khany
  • 1,167
  • 15
  • 33
DomJack
  • 4,098
  • 1
  • 17
  • 32
  • Looks like a dup of http://stackoverflow.com/questions/17299512 – Günter Zöchbauer Jan 17 '15 at 08:54
  • The question is more about accessing a file in an external package. From what I can tell, that question was about local imports only. There are easy enough work-arounds, I know - a minimal new file that simply imports the external package and has a main that simply redirects to the import - but for such a well designed language, I'd be surprised if there wasn't a much more elegant way. – DomJack Jan 17 '15 at 12:10
  • Isolates are still work in progress, don't expect too much. – Günter Zöchbauer Jan 17 '15 at 12:12
  • Sure. Thought there might be something really obvious I was missing. Thanks. – DomJack Jan 17 '15 at 12:35

0 Answers0