env_vars 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 58

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 pub get

Alternatively, your editor might support 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:env_vars/env_vars.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
30
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
67
Overall:
Weighted score of the above. [more]
58
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (package_info).

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.

Package is getting outdated. (-3.29 points)

The package was last published 53 weeks ago.

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+1 0.4.0+9
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test