image_res 0.2.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

Image Res #

pub package

A command-line tool which simplifies a task of placing image files into appropriate folders based on their resolution. Refer to https://flutter.dev/docs/development/ui/assets-and-images#loading-images for further information regarding how Flutter manages resolution-appropriate images. To put it another way, when you place your image assets in a Flutter project and run this plugin. It'll look into all images' filename and automatically move them to appropriate-resolution folders.

For example, if you place images in the asset folder as shown below:

assets/
+-- images/
|   +-- icons/
|   |   +-- search.png
|   |   +-- search@2x.png
|   |   +-- search@3x.png
|   +-- logo.png
|   +-- logo@2x.png
|   +-- logo@3x.png

After running this plugin (with a configuration file in the project's root directory), the images whose filename includes a resolution indicator will be moved as follows:

assets/
+-- images/
|   +-- 2.0x/
|   |   +-- logo.png
|   +-- 3.0x/
|   |   +-- logo.png
|   +-- icons/
|   |   +-- 2.0x/
|   |   |   +-- search.png
|   |   +-- 3.0x/
|   |   |   +-- search.png
|   |   +-- search.png
|   +-- logo.png

Getting Started #

  1. Install the image_res plugin by adding it in pubspec.yaml under dev_dependencies section and run flutter packages get
     dev_dependencies: 
         image_res: ^0.2.2
    
  2. Create a new configuration file called image_res.yaml in the project's root directory
     # The organizer recursively looks into all files in the `asset_folder_path`. (relative to the project's root)
     asset_folder_path: assets/images/
    
     # The organizer only arranges files with their extension listed in the `file_extensions`.
     file_extensions:
         - .jpg
         - .png
    
     # The organizer uses `resolution_indicator` to extract a resolution's part from the filename.
     # The `resolution_indicator` must conform to the following pattern:
     #   '[start_token]{N}[end_token]' where
     #       - [start_token]: A token that indicates a starting point of the resolution's part.
     #       - [end_token]: A token that indicates an ending point of the resolution's part.
     #
     # Valid `resolution_indicator`s along with example filenames that they can detect are shown below.
     #   '@{N}x': logo@2x.png, logo@2.0x.png, @2.0xlogo.png
     #   '--{N}#': logo--2#.png, logo--2.0#.png, --2.0#logo.png
     resolution_indicator: '@{N}x'
    
     # If `allow_overwrite` is true when there is the same filename already existing in a target folder, the organizer will replace it.
     allow_overwrite: false
    
    
  3. Run the plugin in the project's root directory. See Available CLI Commands
     flutter packages pub run image_res:main <command>
    

Note that this plugin can be installed globally by flutter packages pub global activate image_res. Instead of typing a long command shown above, you can run it by just imgres.

If you encounter an issue indicating dart: command not found, please install Dart separately first and try running again.

Available CLI Commands #

CommandsDescription
[blank]Run this plugin once
runRun this plugin once
watchRun this plugin and watch for changes

Usage #

  • If the plugin was installed globally, run it by:
      imgres <command>
    
  • If the plugin was installed locally in a Flutter project, run it by:
      flutter packages pub run image_res:main <command>
    

0.2.2 (16 October 2019) #

  • Update version constraint in pubspec.yaml
  • Fix typos in README.md

0.2.1 (20 June 2019) #

  • Update version constraint in pubspec.yaml

0.2.0 (19 April 2019) #

  • Add an option in image_res.yaml to allow overwriting
  • Update README.md

0.1.1 (17 April 2019) #

  • Fix typos in README.md
  • Add a Pub badge from shields.io

0.1.0 (17 April 2019) #

  • Now this plugin can watch for file changes

0.0.5 (17 April 2019) #

  • Edit README.md

0.0.4 (17 April 2019) #

  • Fix typos in README.md

0.0.2 (17 April 2019) #

  • Change a plugin's name to image_res
  • Add README.md and LICENSE files

0.0.1 (16 April 2019) #

  • Initial a project

example/main.dart

void main() {
  return;
}

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate image_res

2. Use it

The package has the following executables:


$ imgres

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  image_res: ^0.2.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:image_res/image_res.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
43
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

We analyzed this package on Dec 12, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.13.1+4
  • Flutter: 1.12.13+hotfix.2

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
path ^1.6.2 1.6.4
watcher ^0.9.7+12 0.9.7+13
yaml ^2.1.16 2.2.0
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
meta 1.1.8
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test