dotenv2dart 0.0.2

  • Readme
  • Changelog
  • Installing
  • 61

.Env to dart #

This is a dart code generator for dot env (.env) files.

Install #

To install the builder, you have to add it in yours builders section of pubspec.yaml file.

name: example
description: A new Flutter project.
version: 0.0.1

environment:
  sdk: ">=2.1.0 <3.0.0"

builders:            # here
  dotenv2dart: any   # here

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.2

Usage #

Create a .env file in your /lib folder and add your variables.

like:

myMultiplier=4
myAppName=My Awesome App

then, in your dart file you can reference the generated code as:

import 'dot_env.dart' as generated; // This dot_env.dart will be generated inside your .dart_tools folder 

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: generated.MY_APP_NAME,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: generated.MY_APP_NAME),
    );
  }
}

TODO #

  • [ ] Enhance docs.
  • [ ] Give example.
  • [ ] Enhace readme.md for /dotenv_to_dart/ folder

0.0.2 #

  • Improve documentation and example project.

0.0.1 #

  • Initial version, created by amadeu01

Use this package as a library

1. Depend on it

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


dependencies:
  dotenv2dart: ^0.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:dotenv2dart/dotenv2dart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
37
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
61
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:dotenv2dart/dotenv2dart.dart with components: io, build.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dotenv2dart.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
build ^1.1.4 1.2.0
build_config ^0.4.0 0.4.1+1
dart_style ^1.2.8 1.3.2
meta ^1.1.6 1.1.7
path ^1.6.0 1.6.4
recase ^2.0.1 2.0.1
Transitive dependencies
analyzer 0.38.5 0.39.0
args 1.5.2
async 2.4.0
charcode 1.1.2
checked_yaml 1.0.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
csslib 0.16.1
front_end 0.1.27 0.1.28
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
json_annotation 3.0.0
kernel 0.3.27 0.3.28
logging 0.11.3+2
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
pub_semver 1.4.2
pubspec_parse 0.1.5
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+12
yaml 2.2.0
Dev dependencies
pedantic ^1.7.0 1.8.0+1
test ^1.6.0