The Oddler
The Oddler

Reputation: 6698

Importing library in Dart on Windows

I've been trying to make a library in Dart and import it in my project. Though for some reason it won't do it.

Here's how it looks: Bug It says it can't find the library, though the path is correct. I also tried a bunch of other paths:

Note: The project I'm trying to import this library into is located somewhere totally different on my harddrave (my dropbox folder.)

Anyone knows what I should use as path, or how I can import the library properly?

Thanks!

Upvotes: 1

Views: 741

Answers (3)

To import local libraries in dart, I'd recommend using the the path dependency in the pubspec.yaml. This is a much cleaner approach then embedding absolute paths in the dart code.

Read about it here: https://www.dartlang.org/tools/pub/dependencies.html#path-packages

Upvotes: 0

John Evans
John Evans

Reputation: 7383

Try this for windows

#import('/c:/users/pablo/pablo\'s documents/projects/smartcanvas/smartcanvas.dart');

Upvotes: 1

Cutch
Cutch

Reputation: 3575

#import expects a full path or correct relative path to a .dart file that has the #library line.

Here is an example from working code:

https://github.com/johnmccutchan/DartVectorMath/blob/master/test/console_test_harness.dart

At the top you see #import('../lib/vector_math_console.dart');

which is located:

https://github.com/johnmccutchan/DartVectorMath/blob/master/lib/vector_math_console.dart

Chopping off the github url prefix, we are left with:

test/console_test_harness.dart
lib/vector_math_console.dart

The import line uses the correct relative path from test/ into ../lib/ to find vector_math_console.dart (the library).

HTH, John

Upvotes: 3

Related Questions