envsubst 0.2.0

  • README.md
  • Installing
  • Versions
  • 36


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

Use this package as a library

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 flutter 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


We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3


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]
33 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, other

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


  • Package is getting outdated.

    The package was released 86 weeks ago.

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

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 2 hints.

    Run dartfmt to format lib/src/core.dart.

    Run dartfmt to format lib/src/node.dart.

  • 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 1.0.0
Transitive dependencies
persistent 0.8.3 1.0.0
Dev dependencies
test >=0.12.0 <0.13.0