mirror of
https://github.com/java-james/flutter_dotenv.git
synced 2025-07-04 05:18:57 +08:00
feat: variable name in get error message (#53)
This commit is contained in:

committed by
GitHub

parent
4c040be4ff
commit
0c6beec5e0
@ -50,8 +50,10 @@ class DotEnv {
|
||||
|
||||
String get(String name, {String? fallback}) {
|
||||
final value = maybeGet(name, fallback: fallback);
|
||||
assert(value != null, 'A non-null fallback is required for missing entries');
|
||||
return value!;
|
||||
if(value == null){
|
||||
throw Exception('$name variable not found. A non-null fallback is required for missing entries');
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
String? maybeGet(String name, {String? fallback}) => env[name] ?? fallback;
|
||||
|
Reference in New Issue
Block a user