env_vars 1.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new50

env_vars

Container for environment variables

Installation

Add dependency to pubspec.yaml

dependencies:
  ...
  env_vars: ^1.0.0

Run in your terminal

flutter packages get

Example

import 'dart:async';
import 'package:flutter/material.dart';

import 'package:env_vars/env_vars.dart';

void main() {
  EnvVars.set('someCustomKey', 42);
  runApp(new MyApp());
}

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

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Env vars demo'),
      ),
      body: FutureBuilder(
          future: Future.wait([
            EnvVars.appName,
            EnvVars.buildNumber,
            EnvVars.packageName,
            EnvVars.version
          ]),
          builder: (BuildContext context, AsyncSnapshot snapshot) {
            if (snapshot.data != null) {
              final isDev = EnvVars.isDev;
              final appName = snapshot.data[0];
              final buildNumber = snapshot.data[1];
              final packageName = snapshot.data[2];
              final version = snapshot.data[3];
              final someCustomKey = EnvVars.get('someCustomKey');

              final textStyle = Theme.of(context).textTheme.title;

              return Padding(
                padding: EdgeInsets.all(20.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text('Dev: $isDev', style: textStyle),
                    Text('App name: $appName', style: textStyle),
                    Text('Package name: $packageName', style: textStyle),
                    Text('Build number: $buildNumber', style: textStyle),
                    Text('Version: $version', style: textStyle),
                    Text('Some custom key: $someCustomKey', style: textStyle),
                  ],
                ),
              );
            } else {
              return Center(child: CircularProgressIndicator());
            }
          }),
    );
  }
}

License

MIT

1.0.0

  • Initial release

example/lib/main.dart

import 'dart:async';
import 'package:flutter/material.dart';

import 'package:env_vars/env_vars.dart';

void main() {
  EnvVars.set('someCustomKey', 42);
  runApp(new MyApp());
}

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

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Env vars demo'),
      ),
      body: FutureBuilder(
          future: Future.wait([
            EnvVars.appName,
            EnvVars.buildNumber,
            EnvVars.packageName,
            EnvVars.version
          ]),
          builder: (BuildContext context, AsyncSnapshot snapshot) {
            if (snapshot.data != null) {
              final isDev = EnvVars.isDev;
              final appName = snapshot.data[0];
              final buildNumber = snapshot.data[1];
              final packageName = snapshot.data[2];
              final version = snapshot.data[3];
              final someCustomKey = EnvVars.get('someCustomKey');

              final textStyle = Theme.of(context).textTheme.title;

              return Padding(
                padding: EdgeInsets.all(20.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text('Dev: $isDev', style: textStyle),
                    Text('App name: $appName', style: textStyle),
                    Text('Package name: $packageName', style: textStyle),
                    Text('Build number: $buildNumber', style: textStyle),
                    Text('Version: $version', style: textStyle),
                    Text('Some custom key: $someCustomKey', style: textStyle),
                  ],
                ),
              );
            } else {
              return Center(child: CircularProgressIndicator());
            }
          }),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  env_vars: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support 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:env_vars/env_vars.dart';
  
Version Uploaded Documentation Archive
1.0.1 Oct 6, 2018 Go to the documentation of env_vars 1.0.1 Download env_vars 1.0.1 archive
1.0.0 Oct 6, 2018 Go to the documentation of env_vars 1.0.0 Download env_vars 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
9
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.4
  • Flutter: 0.9.5

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

The description is too short. (-20 points)

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
package_info ^0.3.2 0.3.2
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test