Reputation: 26074
I'm struggling with Dart library layout. I tried the following
lib/
A.dart
B.dart
my_lib.dart
where: A.dart
class A {
B myB;
}
B.dart
class A {
B myB;
}
my_lib.dart
#library('my_lib');
#source('A.dart');
#source('B.dart');
But in A.dart, in Dart Editor there is a problem: B - no such type. If I import B.dart in that file, via
#import('B.dart)',
but now it claims that part of library can only contain part directive. According to http://news.dartlang.org/2012/07/draft-spec-changes-to-library-and.html
partDirective:
metadata part stringLiteral “;”
;
But that doesn't work for me either. What am I missing?
Upvotes: 3
Views: 1440
Reputation: 30292
Download the latest SDK and try:
a.dart
class A {
B myB;
}
b.dart
class B {
}
lib.dart
library mylib;
part 'a.dart';
part 'b.dart';
That should work.
Upvotes: 5
Reputation: 908
Due to new release changes the layout has to look like the followed example:
a.dart
part of mylib;
class A {
B myB;
}
b.dart
part of mylib;
class B {
}
lib.dart
library mylib;
part 'a.dart';
part 'b.dart';
Upvotes: 4