Reputation: 9945
Say, I load this script in the browser:
<script src='app.dart' type='application/dart'></script>
Now, in app.dart I have this:
import 'library1.dart';
unleashTheKraken();
Then in library1.dart you'll find this:
library library1;
import 'library2';
And finally in library2.dart we'll have:
library library2;
unleashTheKraken() => print('Unleashing the Kraken')
And the result is: Exception: No top-level method 'unleashTheKraken' declared.
How so?
Upvotes: 0
Views: 44
Reputation: 3832
Because imports don't chain automatically. You have to use the export
statement for that.
library library1;
import "library2.dart";
export "library2.dart";
And to avoid unnecessary code: import
and export
are completely independent. If you don't use unleashTheKraken
in library1 itself, you can omit the import statement and just use export alone.
Upvotes: 2