@@ -50,8 +50,9 @@ class DotEnv {
50
50
51
51
String get (String name, {String ? fallback}) {
52
52
final value = maybeGet (name, fallback: fallback);
53
- if (value == null ){
54
- throw AssertionError ('$name variable not found. A non-null fallback is required for missing entries' );
53
+ if (value == null ) {
54
+ throw AssertionError (
55
+ '$name variable not found. A non-null fallback is required for missing entries' );
55
56
}
56
57
return value;
57
58
}
@@ -65,7 +66,8 @@ class DotEnv {
65
66
/// exists but can not be parsed as an [int] .
66
67
int getInt (String name, {int ? fallback}) {
67
68
final value = maybeGet (name);
68
- assert (value != null || fallback != null , 'A non-null fallback is required for missing entries' );
69
+ assert (value != null || fallback != null ,
70
+ 'A non-null fallback is required for missing entries' );
69
71
return value != null ? int .parse (value) : fallback! ;
70
72
}
71
73
@@ -78,7 +80,8 @@ class DotEnv {
78
80
/// exists but can not be parsed as a [double] .
79
81
double getDouble (String name, {double ? fallback}) {
80
82
final value = maybeGet (name);
81
- assert (value != null || fallback != null , 'A non-null fallback is required for missing entries' );
83
+ assert (value != null || fallback != null ,
84
+ 'A non-null fallback is required for missing entries' );
82
85
return value != null ? double .parse (value) : fallback! ;
83
86
}
84
87
@@ -91,7 +94,8 @@ class DotEnv {
91
94
/// exists but can not be parsed as a [bool] .
92
95
bool getBool (String name, {bool ? fallback}) {
93
96
final value = maybeGet (name);
94
- assert (value != null || fallback != null , 'A non-null fallback is required for missing entries' );
97
+ assert (value != null || fallback != null ,
98
+ 'A non-null fallback is required for missing entries' );
95
99
if (value != null ) {
96
100
if (['true' , '1' ].contains (value.toLowerCase ())) {
97
101
return true ;
@@ -110,7 +114,10 @@ class DotEnv {
110
114
/// Loads environment variables from the env file into a map
111
115
/// Merge with any entries defined in [mergeWith]
112
116
Future <void > load (
113
- {String fileName = '.env' ,Parser parser = const Parser (),Map <String , String > mergeWith = const {}, bool isOptional = false }) async {
117
+ {String fileName = '.env' ,
118
+ Parser parser = const Parser (),
119
+ Map <String , String > mergeWith = const {},
120
+ bool isOptional = false }) async {
114
121
clean ();
115
122
List <String > linesFromFile;
116
123
try {
@@ -123,7 +130,9 @@ class DotEnv {
123
130
}
124
131
}
125
132
126
- final linesFromMergeWith = mergeWith.entries.map ((entry) => "${entry .key }=${entry .value }" ).toList ();
133
+ final linesFromMergeWith = mergeWith.entries
134
+ .map ((entry) => "${entry .key }=${entry .value }" )
135
+ .toList ();
127
136
final allLines = linesFromMergeWith..addAll (linesFromFile);
128
137
final envEntries = parser.parse (allLines);
129
138
_envMap.addAll (envEntries);
@@ -136,7 +145,9 @@ class DotEnv {
136
145
Map <String , String > mergeWith = const {}}) {
137
146
clean ();
138
147
final linesFromFile = fileInput.split ('\n ' );
139
- final linesFromMergeWith = mergeWith.entries.map ((entry) => "${entry .key }=${entry .value }" ).toList ();
148
+ final linesFromMergeWith = mergeWith.entries
149
+ .map ((entry) => "${entry .key }=${entry .value }" )
150
+ .toList ();
140
151
final allLines = linesFromMergeWith..addAll (linesFromFile);
141
152
final envEntries = parser.parse (allLines);
142
153
_envMap.addAll (envEntries);
@@ -146,7 +157,8 @@ class DotEnv {
146
157
/// True if all supplied variables have nonempty value; false otherwise.
147
158
/// Differs from [containsKey] (dart:core) by excluding null values.
148
159
/// Note [load] should be called first.
149
- bool isEveryDefined (Iterable <String > vars) => vars.every ((k) => _envMap[k]? .isNotEmpty ?? false );
160
+ bool isEveryDefined (Iterable <String > vars) =>
161
+ vars.every ((k) => _envMap[k]? .isNotEmpty ?? false );
150
162
151
163
Future <List <String >> _getEntriesFromFile (String filename) async {
152
164
try {
0 commit comments