nomirrorsmap 1.1.2

  • Installing
  • Versions
  • 73

NoMirrorsMap Build Status Coverage Status


NoMirrorsMap allows you to map objects in one format to objects in another format. For example, you can use it to serialise and deserialise native dart objects to and from Json, or to map an object of one type to an object of another type with the same property names.

NoMirrorsMap does this without using Mirrors (hence the name...). It uses a transformer to create a map file for all the objects that you may need to map, and uses that map file at runtime to avoid the use of Mirrors and to significantly improve the mapping performance.


Before you can use NoMirrorsMap, you need to add a transformer entry to your pubspec.yaml file and you need to tell NoMirrorsMap which types you are going to be mapping so the transformer knows which types it needs to generate mapping data for. You can do this in two ways:

  1. You can decorate any types that need to be mapped with the @Mappable() attribute.
  2. You can add an entry for a library under the transformer declaration in your pubspec.yaml file, which will cause NoMirrorsMap to generate mapping data for ALL the types in that library.

NoMirrorsMap works via a two step process; first the object to be mapped from one format to another is mapped into an intermediate format, and then that intermediate format is mapped to the final target format. While the object is in its intermediate format, you have the opportunity to manipulate the object. In the current codebase, NoMirrorsMap contains manipulators which can change the casing of properties to PascalCase, or to camelCase, or to change the target type.

When you call the convert method, you supply the object to be mapped, the converter to convert the object to the intermediate format, the converter to convert the intermediate format to the final format, and an optional list of manipulators to modify the intermediate format before it is run through the target format converter.

So for example, to convert an object to Json, you would do this:

var json = new NoMirrorsMap().convert(objectToMap, new ClassConverter(), new JsonConverter());

To convert an object to Json, changing the casing of the properties to PascalCase in the process, you would do this:

var json = new NoMirrorsMap().convert(objectToMap, new ClassConverter(), new JsonConverter(), [ new PascalCaseManipulator() ]);

Other manipulators include:

  • PascalCaseManipulator
  • CamelCaseManipulator
  • TypeToTypeManipulator

We recommend creating static methods for doing common mappings. For example you might create the following static methods for encoding and decoding json:

class Json {
	static String encode( dynamic obj ) {
    	return new NoMirrorsMap().convert( obj, new ClassConverter(), new JsonConverter() );

    static String decode( string json, Type type ) {
    	return new NoMirrorsMap().convert( json, new JsonConverter(), new ClassConverter( startType: type ) );

NoMirrorsMap has a few converters within the codebase by default, but you can easily write your own if you need to map to or from any other formats you may need (XML, CSV etc). Feel free to submit these in a pull request!

Basic Example Using The @Mappable() Attribute


	nomirrorsmap: any
	- nomirrorsmap


import 'package:nomirrorsmap/nomirrorsmap.dart';

	var obj = new EncodableObject() = 1;
	var json = new NoMirrorsMap().convert(obj, new ClassConverter(), new JsonConverter());

class EncodableObject {
	int id;

Basic Example Using Library Declaration in pubspec.yaml


	nomirrorsmap: any
	- nomirrorsmap:
        	- "my_library"


import 'package:nomirrorsmap/nomirrorsmap.dart';
import 'my_library.dart';

	var obj1 = new FirstEncodableObject() = 1;
    var obj2 = new SecondEncodableObject() = 2;

    var mapper = new NoMirrorsMap();
	var json1 = mapper.convert(obj1, new ClassConverter(), new JsonConverter());
    var json2 = mapper.convert(obj2, new ClassConverter(), new JsonConverter());



library my_library;

class FirstEncodableObject {
	int id;

class SecondEncodableObject {
	int id;

Bitdeli Badge

1. Depend on it

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

  nomirrorsmap: "^1.1.2"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:nomirrorsmap/nomirrorsmap.dart';
Version Uploaded Documentation Archive
1.1.2 Jul 27, 2017 Go to the documentation of nomirrorsmap 1.1.2 Download nomirrorsmap 1.1.2 archive
1.1.1 Feb 20, 2017 Go to the documentation of nomirrorsmap 1.1.1 Download nomirrorsmap 1.1.1 archive
1.1.0 Sep 5, 2016 Go to the documentation of nomirrorsmap 1.1.0 Download nomirrorsmap 1.1.0 archive
1.0.27 Aug 26, 2016 Go to the documentation of nomirrorsmap 1.0.27 Download nomirrorsmap 1.0.27 archive
1.0.26 Aug 3, 2016 Go to the documentation of nomirrorsmap 1.0.26 Download nomirrorsmap 1.0.26 archive
1.0.25 Jul 29, 2016 Go to the documentation of nomirrorsmap 1.0.25 Download nomirrorsmap 1.0.25 archive
1.0.24 Apr 28, 2016 Go to the documentation of nomirrorsmap 1.0.24 Download nomirrorsmap 1.0.24 archive
1.0.23 Dec 4, 2015 Go to the documentation of nomirrorsmap 1.0.23 Download nomirrorsmap 1.0.23 archive
1.0.22 Dec 3, 2015 Go to the documentation of nomirrorsmap 1.0.22 Download nomirrorsmap 1.0.22 archive
1.0.21 Dec 3, 2015 Go to the documentation of nomirrorsmap 1.0.21 Download nomirrorsmap 1.0.21 archive

All 48 versions...


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Feb 16, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
69 / 100
Code health derived from static analysis. [more]
85 / 100
Reflects how tidy and up-to-date the package is. [more]
65 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:nomirrorsmap/nomirrorsmap.dart.


  • Fix lib/src/transformer/generators/properties_generator.dart.

    Strong-mode analysis of lib/src/transformer/generators/properties_generator.dart failed with the following error:

    line: 11 col: 32
    The getter 'isEnum' isn't defined for the class 'Element'.

  • Fix lib/src/transformer/generators/enums_generator.dart.

    Strong-mode analysis of lib/src/transformer/generators/enums_generator.dart failed with the following error:

    line: 10 col: 60
    The getter 'isEnum' isn't defined for the class 'Element'.

  • Fix further 3 Dart files.

    Similar analysis of the following files failed:

    • lib/src/transformer/generators/class_generator.dart
    • lib/src/transformer/map_generator_transformer.dart
    • lib/src/transformer/mappings_generator.dart
  • Maintain

    Changelog entries help clients to follow the progress in your code.

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 3 error(s) and 0 warning(s).

  • Use constrained dependencies.

    The pubspec.yaml contains 2 dependencies without version constraints. Specify version ranges for the following dependencies: code_transformers, dart_style.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use nomirrorsmap.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.9.0 <2.0.0
code_transformers any 0.5.1+4
dart_style any 1.0.9+1
path >=1.0.0 <2.0.0 1.5.1
reflective ^0.0.29 0.0.29
Transitive dependencies
analyzer 0.31.1 0.31.2-alpha.0
args 1.3.0
async 2.0.3 2.0.4
barback 0.15.2+14
charcode 1.1.1
cli_util 0.1.2+1
collection 1.14.5
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
front_end 0.1.0-alpha.9 0.1.0-alpha.10
glob 1.1.5
html 0.13.2+2
isolate 1.1.0
kernel 0.3.0-alpha.9 0.3.0-alpha.10
logging 0.11.3+1
meta 1.1.2
package_config 1.0.3
plugin 0.2.0+2
pool 1.3.4
source_maps 0.10.4
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+7
yaml 2.1.13
Dev dependencies
test 0.12.19+1
transformer_test 0.2.1+1