dartodef 0.1.4

  • README.md
  • Installing
  • Versions
  • 66

dartodef

dartodef is a transformer (preprocessor) for pub build which replaces variable values on compile-time. The values can be defined in the pubspec.yaml. For different environment values create a property in the transformer options for dartodef and pass the name of the property as environment variable to the


## Setup dartodef

**pubspec.yaml**

name: dartodef_sample_setup version: 0.1.0 dependencies: browser: any js: any dartodef: any transformers:

  • dartodef: live: environment: 'live' doIt: true preview: environment: 'preview' doIt: false

**main.dart** (for example)

library sample_app;

import 'package:dartodef/dartodef.dart';

@Definition(name:'environment') const String ENV = 'development';

class Test { @Definition(name:'doIt') static bool done = false; }


Running pub build now:

DARTODEF=live pub build


If no environment is set the default values will be used.

## Available types

... transformers:

  • dartodef: live: string: hallo other_string: "hallo test" int: 1 num: 1 double: 1.1 bool: true list: [1, 2, "simple", 1.1, true] map: key: "value" key2: 1

Only simple types can be used. Lists and maps will be serialized.

## What you need to know

- always import dartodef as it is. DO NOT USE "as"
- only variables that are already initialized can be used. And the initialization needs to match the type (for example mapping on string when code looks like: "String variable = null;" failes)
- use const if you want to make sure that dead is removed

## Plans for the future

- load values for each environment from dart scripts or other external files (JSON, YAML)


### How to run tests

DARTODEF=test pub serve --port=4444 test/ pub run test --pub-serve=4444

Use this package as a library

1. Depend on it

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


dependencies:
  dartodef: ^0.1.4

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:dartodef/dartodef.dart';
  
Version Uploaded Documentation Archive
0.1.4 Aug 26, 2017 Go to the documentation of dartodef 0.1.4 Download dartodef 0.1.4 archive
0.1.3 Apr 8, 2017 Go to the documentation of dartodef 0.1.3 Download dartodef 0.1.3 archive
0.1.2 Nov 20, 2016 Go to the documentation of dartodef 0.1.2 Download dartodef 0.1.2 archive
0.1.1 Jan 24, 2014 Go to the documentation of dartodef 0.1.1 Download dartodef 0.1.1 archive
0.1.0 Dec 5, 2013 Go to the documentation of dartodef 0.1.0 Download dartodef 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
47
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
64
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status tool failures using:

  • Dart: 2.0.0
  • pana: 0.11.8

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.0.0.
 
 Because dartodef depends on analyzer >=0.9.1 <0.32.4 which requires SDK version >=0.8.8 <2.0.0-∞, version solving failed.

Fix platform conflicts.

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Maintain CHANGELOG.md.

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

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 of the API.

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 dartodef.dart.

Format lib/transformer.dart.

Run dartfmt to format lib/transformer.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.0