2013-10-27 43 views

回答

2

查找腳本目錄的最簡單方法是使用路徑包。

import "package:path/path.dart" show dirname; 
import 'dart:io' show Platform; 

main() { 
    print(dirname(Platform.script.toString())); 
} 

把路徑封裝到您的pubspec.yaml:

dependencies: 
    path: any 

而且一定要運行pub get下載和鏈接路徑封裝。

+0

您在10月27日自己提出這個問題,但在10月26日宣佈「Platform」類將被轉換爲單獨的包「包」。也許你宣佈了這些改變? – mezoni

+0

我認爲這個決定被恢復了。平臺在dart:io –