Add AngelEnv class
This commit is contained in:
parent
4df78749f1
commit
1b1c190de4
1 changed files with 27 additions and 0 deletions
27
lib/src/core/env.dart
Normal file
27
lib/src/core/env.dart
Normal 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';
|
||||||
|
}
|
Loading…
Reference in a new issue