ex_map 0.10.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 12

c9 - editor

Build Status pub package

A library for writing pretty simple object class with Map interface.

Use transformer:

transformers:
  - ex_map

And that:

library ex_map_test;
import 'package:ex_map/ex_map.dart';

@ExMap
class TestMap extends ExtendedMap {
  @ExKey()
  int id;
  
  @ExKey(protected: true, type: int)
  String integerField; 
  
  @ExKey(type: String)
  var testField;
  
  var notAnnotatedProperty;
}

will be transformed to:

library ex_map_test;
import 'package:ex_map/ex_map.dart';

@ExMap
class TestMap extends ExtendedMap {
  TestMap({int id, int integerField, String testField}) {
    protectedKeys.addAll(['integerField']);
    types = {'id': int, 'integerField': int, 'testField': String};
  }
  
  get id => this['id'];
  set id(value) => this['id'] = value;
  
  get integerField => this['integerField'];
  set integerField(value) => setProtectedField('integerField', value);
  
  get testField => this['testField'];
  set testField(value) => this['testField'] = value;
  
  var notAnnotatedProperty;
}

protectedKeys - can not be set differently than through special method. (setProtectedField) That property can be established only through the operator: "."

types - need to check type of value before save:

class FieldsTestMap extends ExtendedMap {
  FieldsTestMap({id, integerField, testField}) {
    types = {
      'stringField': String,
      'intField': int,
      'doubleField': double,
      'dateField': DateTime,
      'boolField': bool
    };
  }
  
  /// Test
  group('The extended map', () {
    test('has right types', () {
      FieldsTestMap map = new FieldsTestMap();

      map['stringField'] = 1;
      expect(map.stringField, equals('1'));

      map['stringField'] = '2';
      expect(map.stringField, equals('2'));

      map['intField'] = '1';
      expect(map.intField, equals(1));

      map['intField'] = 2;
      expect(map.intField, equals(2));

      map['doubleField'] = '2.2';
      expect(map.doubleField, equals(2.2));

      map['doubleField'] = 2.1;
      expect(map.doubleField, equals(2.1));

      DateTime date = new DateTime.now();
      map['dateField'] = date.toString();
      expect(map.dateField, equals(date));

      map['dateField'] = date;
      expect(map.dateField, equals(date));

      map['boolField'] = 'true';
      expect(map.boolField, equals(true));

      map['boolField'] = false;
      expect(map.boolField, equals(false));
    });
  });
TODO:
  • Default constructor check in transformer

ExMap Change Log

0.10.2

  • Update readme
  • Update version

0.10.1

  • Update readme

example/example.dart

library example;

import 'dart:html';
import 'package:ex_map/ex_map.dart';

@ExMap
class ExampleMap extends ExtendedMap {
  @ExKey()
  int id;

  @ExKey(protected: true, type: int)
  int integerField = 1;

  @ExKey(type: String)
  var testField = 'test';
}

main() {
  ExampleMap exampleMap = new ExampleMap();
  exampleMap['id'] = 1;
  querySelector('body')
    ..appendText('keys: ${exampleMap.keys.toString()}')
    ..append(new Element.br())
    ..appendText('id: ${exampleMap.id}')
    ..append(new Element.br())
    ..appendText('integerField: ${exampleMap.integerField}')
    ..append(new Element.br())
    ..appendText('testField: ${exampleMap["testField"]}');
}

1. Depend on it

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


dependencies:
  ex_map: "^0.10.2"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:ex_map/ex_map.dart';
        
Version Uploaded Documentation Archive
0.10.2 Aug 15, 2016 Go to the documentation of ex_map 0.10.2 Download ex_map 0.10.2 archive
0.10.1 Aug 15, 2016 Go to the documentation of ex_map 0.10.1 Download ex_map 0.10.1 archive
0.9.9 Aug 14, 2016 Go to the documentation of ex_map 0.9.9 Download ex_map 0.9.9 archive
0.9.8 Aug 15, 2016 Go to the documentation of ex_map 0.9.8 Download ex_map 0.9.8 archive

Analysis

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

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
16 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
36 / 100
Overall score:
Weighted score of the above. [more]
12

Platforms

Detected platforms: unsure

Error(s) prevent platform classification.

Suggestions

  • Fix lib/src/extended_map.dart.

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

    line: 81 col: 3
    Invalid override. The type of 'ExtendedMap.[]=' ('(K, V) → void') isn't a subtype of 'Map<dynamic, dynamic>.[]=' ('(dynamic, dynamic) → void').

  • Fix lib/transformer.dart.

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

    line: 3 col: 8
    Target of URI doesn't exist: 'package:analyzer/analyzer.dart'.

  • Fix platform conflicts.

    Make sure none of the libraries use mutually exclusive dependendencies.

  • Fix issues reported by dartanalyzer.

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

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.14.0 <2.0.0
barback ^0.15.2+8 0.15.2+14
Transitive dependencies
async 2.0.3 2.0.4
charcode 1.1.1
collection 1.14.5
path 1.5.1
pool 1.3.4
source_span 1.4.0
stack_trace 1.9.2
Dev dependencies
test ^0.12.15+3
transformer_test ^0.2.1