-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironment.dart
More file actions
40 lines (33 loc) · 949 Bytes
/
environment.dart
File metadata and controls
40 lines (33 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import 'dart:io';
/// Wraps access to Environment variables
/// Allows faking for testing
class Environment {
static String raygunAppIdKey = 'RAYGUN_APP_ID';
static String raygunTokenKey = 'RAYGUN_TOKEN';
final String? raygunAppId;
final String? raygunToken;
static Environment? _instance;
/// Singleton instance access
/// Will init if not already
static Environment get instance {
_instance ??= Environment._init();
return _instance!;
}
/// For testing purposes
static void setInstance(Environment instance) {
_instance = instance;
}
/// Create custom instance
Environment({
required this.raygunAppId,
required this.raygunToken,
});
factory Environment._init() {
final raygunAppId = Platform.environment[raygunAppIdKey];
final raygunToken = Platform.environment[raygunTokenKey];
return Environment(
raygunAppId: raygunAppId,
raygunToken: raygunToken,
);
}
}