dartodef 0.1.4

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


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:

  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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.0