How I can get path of the current script (not executable) in Dart?
For example. In PHP we have __DIR__
constant, that reffer to script directory. If we
You've said that when you run test.dart
, the current directory is /path/to/lib/tests
. So you should be able to use a relative path to open rules.json
. The path is ../rules/rules.json
(or of course, ..\rules\rules.json
on Windows, you can get the separator from Platform.pathSeparator).
Alternately, apparently you can get a Uri for the current script (if supported by the platform) from Platform.script.