envsubst 0.2.0

  • README.md
  • Installing
  • Versions
  • 43


Build Status

Docker style environment variables substitution for Dart.

Environment variables are notated either with $variable_name or ${variable_name}. They are treated equivalently and the brace syntax is typically used to address issues with variable names with no whitespace, like ${foo}_bar.

The ${variable_name} syntax also supports a few of the standard bash modifiers as specified below:

  • ${variable:-word} indicates that if variable is set then the result will be that value. If variable is not set then word will be the result.
  • ${variable:+word} indicates that if variable is set then word will be the result, otherwise the result is the empty string.

In all cases, word can be any string, including additional environment variables.

Escaping is possible by adding a \ before the variable: $foo or ${foo}, for example, will translate to $foo and ${foo} literals respectively.


Using envsubst programatically

import 'package:envsubst/envsubst.dart';

main() {
  String input = r'Hello $HOME';
  String output = envSubst(input);
  print(output); // print 'Hello /Users/kseo'

Using via cli

$ envsubst.dart < input.txt > output.txt
$ echo 'welcome $HOME' | envsubst

Other Projects

If you are a Go programmer, see a8m/envsubst.



  • Add a command line tool
  • Add EnvSubst class which implements Converter<String, String> interface


  • Fix a parse error


  • Initial version

1. Depend on it

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

  envsubst: "^0.2.0"

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:envsubst/envsubst.dart';
Version Uploaded Documentation Archive
0.2.0 Oct 12, 2016 Go to the documentation of envsubst 0.2.0 Download envsubst 0.2.0 archive
0.1.1 Sep 30, 2016 Go to the documentation of envsubst 0.1.1 Download envsubst 0.1.1 archive
0.1.0 Sep 30, 2016 Go to the documentation of envsubst 0.1.0 Download envsubst 0.1.0 archive


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

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

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


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


Detected platforms: Flutter, other

Primary library: package:envsubst/envsubst.dart with components: io.


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • 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.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
parsers ^0.14.5 0.14.5
Transitive dependencies
persistent 0.8.3
Dev dependencies
test >=0.12.0 <0.13.0