Tuesday, December 4, 2018

Flutter: How to keep assets - images and fonts

An asset is a file that is bundled and deployed with your app, and is accessible at runtime. Common types of assets include static data (for example, JSON files), configuration files, icons, and images (JPEG, WebP, GIF, animated WebP/GIF, PNG, BMP, and WBMP).


Flutter uses the pubspec.yaml file, located at the root of your project, to identify assets required by an app.

Here is an example:

flutter:
  assets:
    - assets/my_icon.png
    - assets/background.png

To include all assets under a directory, specify the directory name with the / character at the end:

flutter:
  assets:
    - assets/

Note that only files located directly in the directory will be included; to add files located in subdirectories, create an entry per directory.

And to note, wow,

Spaces are significant in YAML

assets is indented too far

flutter_test:
  sdk: flutter

flutter:
  uses-material-design: true
  assets:
    - loadjson/person.json



References:
https://flutter.io/docs/development/ui/assets-and-images

No comments:

Post a Comment