Add AngelEnv class

This commit is contained in:
Tobe O 2019-03-11 11:17:44 -04:00
parent 4df78749f1
commit 1b1c190de4

27
lib/src/core/env.dart Normal file
View file

@ -0,0 +1,27 @@
import 'dart:io';
/// A constant instance of [AngelEnv].
const AngelEnv angelEnv = const AngelEnv();
/// Queries the environment's `ANGEL_ENV` value.
class AngelEnv {
final String _customValue;
/// You can optionally provide a custom value, in order to override the system's
/// value.
const AngelEnv([this._customValue]);
/// Returns the value of the `ANGEL_ENV` variable; defaults to `'development'`.
String get value =>
(_customValue ?? Platform.environment['ANGEL_ENV'] ?? 'development')
.toLowerCase();
/// Returns whether the [value] is `'development'`.
bool get isDevelopment => value == 'development';
/// Returns whether the [value] is `'production'`.
bool get isProduction => value == 'production';
/// Returns whether the [value] is `'staging'`.
bool get isStaging => value == 'staging';
}