1
假設我有這樣的:如何從導入的庫中爲Dart下面導入的所有庫訪問函數/類?
benchmark.dart:
library benchmark;
benchmark() {...}
app.dart:
import 'benchmark.dart'; // functions from this lib are now accessible in this file
export 'benchmark.dart'; // does this make them accessible in all files imported below?
import 'model.dart';
void main() {
doSomething();
}
model.dart
doSomething() {
benchmark(); // => Error, no such method, unless
// I import 'benchmark.dart' above in this file!
}
這是正確的行爲嗎?如何使基準可訪問沒有在model.dart中導入該庫?