我正在Dart編寫一個庫,我在庫文件夾下有靜態文件。我希望能夠閱讀這些文件,但我不知道如何檢索它的路徑......沒有__FILE__
或$0
像其他一些語言一樣。在Dart的庫中讀取靜態文件?
更新:看來我還不夠清楚。讓這個幫助你理解我:
test.dart
import 'foo.dart';
void main() {
print(Foo.getMyPath());
}
foo.dart
library asd;
class Foo {
static Path getMyPath() => new Path('resources/');
}
它給了我錯誤的文件夾位置。它給我的路徑test.dart
+ resources/
,但我想要的路徑爲foo.dart
+ resources/
。
它實際上在路徑中有文件名,但這是一個小問題。 – Tower