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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With