For example, I have this structure:
/home/user <- my current dir
/home/user/app/bin/main.dart <- entry point of my application
How I can get a path to the folder from which the script has been started? For example, I start main.dart from /home/user folder by:
dart app/bin/main.dart
Inside main.dart I need get the path /home/user. Is this possible?
I assume this is what you are looking for.
import 'dart:io';
void main() {
print(Platform.script);
print(Platform.script.toFilePath(windows: true));
// or
print(Directory.current.absolute.path);
}
see also How do I get the script path in Dart?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With