I am writing a package that downloads additional data from a directory liband would like to provide an easy way to load this data like this:
const dataPath = 'mypackage/data/data.json';
initializeMyLibrary(dataPath).then((_) {
// library is ready
});
I created two separate libraries browser.dartand standalone.dart, similarly to how it is done in the Intl package .
Downloading this data from a “browser” environment is pretty easy, but when it comes to a “standalone” environment, it’s not so easy because of the command pub run.
When the script works with a simple one $ dart myscript.dart, I can find the package path using dart: io.Platform Platform.script and Platform.packageRoot.
But when the script works with $ pub run tool/mytool, the correct way to load data should be:
- , script pub
- - pub
- , pub, .
, script pub run, Platform.script /mytool .
, , , script pub run pub?