Where to put Dart package assets - dart

I am writing a Dart package, and I would like to have a resources directory that Pub includes with the package. I want this directory to be accessible relative to the root file of the package. Is there a standard way of doing this with Pub?
Thanks!

In general only files within lib/** can be used from other packages, therefore this is where you should put them.
Your question doesn't contain a lot of information what kind of package your want to create and what kind of resources you want to ship with the package or how the resources are supposed to be used by the user of the package. There are a few open bugs about other ways to make resources available to running applications.

Assets are available within the lib folder.
Create a folder under lib called assets, i.e. /lib/assets
Then link it in pubspec.yaml:
assets:
- assets/something.jpeg

Related

dart language: How to get all the classes available to import?

Programmatically I want to get all dart files available to import.
How can I achievement this? (programmatically)
In which environment do you want that?
If it's for a single Pub package, ensure that dart pub get has been run, then parse the .dart_tool/package_config.json file and find the roots of all the packages. Then search through those directories for all dart files that are not part files (does not start with part of ...;). The rest should be Dart library files which can be imported.
If you only want the packages that can be imported from inside lib/, you may want to parse the pubspec.yaml file too, so you can ignore the dev_dependencies.
Then you may also want to list the available dart:... platform libraries. Which are available depends on which platform you compile for. You need to figure that out somehow, then you should just keep a list for each platform.

iOS - how do I include javascript files that can be referred by relative paths to project?

Basically I want to use relative path in my html and js files that I imported to the project. It seems that xcode puts those bundle files all at the same level if I import files as group reference. So if I then get rid of all relative paths in my code it would work. But if I import them as folder reference as following links suggested none of those files will appear in Copy Bundle Resources (neither in compiled sources).
Load resources from relative path using local html in uiwebview
UIWebView doesn't load external Javascript file
Any help will be appreciated.
I managed to resolve my issue. What I did wrong was import the entire folder as folder reference that would expose the folder appearing in the root directory as the result. I could refer every files with that directory (e.g. root/js/abc.js) but that'd be bad.
I don't know if it's the best way to resolve but here is what I have done. I created one group and put everything else in that group except importing all sub folders as folder references. In that way all files in the root group can use relative paths without errors.
Note: all the files in the folder reference still don't appear in bundle resources and I still don't know how other people (in the links I posted) got it done.
You could put your front-end files into a real folder, then add the folder to your XCode project(don't forget to check "copy if needed", not as reference).

Dart project structure for apps (not libs)

I am trying to understand Dart's recommended project structure and not seeing the "forest through the trees".
So, if my project is intended to be a reusable library, say, a logging framework of some sort, then if I understand the above link correctly, I want all of my development to be under a lib and lib/src directory.
But what if I am building a web app? Where do my Dart source files go? Under packages? Specifically:
Where do I place Dart source files for a web app (not a lib)?
Are my web app's "packages" just directories that are logically organized similar to Java packages?
Does Dart recommend a 1-class-per-file convention for its source code?
1)
your_app_package/web
your_app_package/web/src/xxx
static content like jpg, css go to
* your_app_package/asset
2) the packages directory is maintained automatically. You configure in the file pubspec.yaml which 3rd party libraries you want to use and then call pub get or pub upgrade and the packages directory is updated automatically (the Darteditor does this automatically when you update pubspec.yaml).
3) not that I know of.
I had some problems putting additional classed in the code file of a Polymer element though. But I guess this is just a temporary limitation of Polymer.

Polymer Dart package layout conventions?

I'm currently working on a project which contains a number of components (polymer elements). All said and done, I'll probably be looking at around 10+ components for the application. At the moment, following Pub's Package Layout Conventions each .html and associated .dart file is in the web/ directory.
It would be nice to have them in lib/src/ of my application and only have the main files in web/ however at the moment <link ref="import" href="package:my_app/src/my_component.html"> will not work (See Issue 12867).
Are there currently any conventions in use to handle multiple (private) components for an app? Should I create a web/src/ directory to load imports/source files relative to the web/ directory? Would it even make sense to keep Polymer Element .html files in lib/src/ (assuming it was supported) as they're not pure dart files as traditionally recommended/expected in a pub package layout?
As far as I understand, package: works only for external components (dependencies declared in pubspec.yaml), and the default path is the packages folder (created by pub install). See the getting started section here: Dart Pub
I keep components in their own folders under the web directory so web/component1, web/component2 and so on and I use relative links to import across components. Not sure if this is the best practice but it works.

where to find "package com.rim.samples.docs.notifications;"

i a developing blackberry aplication using eclipse can any one tell where to find the following library
package com.rim.samples.docs.notifications;
i have downloaded it from blackberry site but i dont know how to use it
com.rim.samples.docs namespace is common for samples BlackBerry Application Developer Guide.
On the other hand, "package" token defines the packege namespace, not the import.
If you have downloaded code and post it to namespace with other name, you may have trouble to compile it. Resolve it in two ways:
1. if your code file is placed directly in project src folder, simply remove
package com.rim.samples.docs.notifications;
from code, this will set namespace to default.
2. in project src folder create folder "com\rim\samples\docs\notifications" and move file to folder "notifications".

Resources