Closed lsgd closed 4 months ago
The pubspec for your project DOES NOT exist in the compiled Flutter application. This package is meant to be used in tools.
@kevmoo Is there a way to read the dependencies or pubspec.yaml content in flutter applications?
@maheshmnj not unless you package the pubspec somehow in the build process. It's like asking if you can read the source code of a Dart file in a flutter application. It's just not there (unless you do work) after the app is built and deployed.
I'm having a hard time to parse the pubspec.yaml, mainly I can't access the content of my pubspec.yaml
If I try to simply read it with File(), I get the following error:
If I use rootBundle, I get another error:
I replaced
<my_package_name>
with the name specified in pubspec.yaml, as well as with the package attribute value<manifest [...] package="tld.mydomain.myapp">
from the AndroidManifest.xml. Both times it failed.My code looks the following:
and my file structure looks like this
I haven't modified anything else, like I didn't add "pubspec.yaml" to assets in pubspec.yaml or similar. But even if I add "pubspec.yaml", the code fails with the PathNotFoundException error. Do I miss something?
It would be really helpful if the README would contain a working example to showcase how to use this module. Thanks a lot.