fix .env loading
This commit is contained in:
@@ -100,7 +100,15 @@ class DeckRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> loadApiKey() async {
|
Future<String?> loadApiKey() async {
|
||||||
final envApiKey = dotenv.env['WANIKANI_API_KEY'];
|
String? envApiKey;
|
||||||
|
try {
|
||||||
|
envApiKey = dotenv.env['WANIKANI_API_KEY'];
|
||||||
|
} catch (e) {
|
||||||
|
// dotenv is not initialized, so we can't get the key.
|
||||||
|
// This is expected in release builds.
|
||||||
|
envApiKey = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (envApiKey != null && envApiKey.isNotEmpty) {
|
if (envApiKey != null && envApiKey.isNotEmpty) {
|
||||||
_apiKey = envApiKey;
|
_apiKey = envApiKey;
|
||||||
return _apiKey;
|
return _apiKey;
|
||||||
@@ -405,4 +413,4 @@ class DeckRepository {
|
|||||||
await saveVocabulary(items);
|
await saveVocabulary(items);
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,5 +34,4 @@ flutter_icons:
|
|||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
assets:
|
assets:
|
||||||
- assets/sfx/confirm.mp3
|
- assets/sfx/confirm.mp3
|
||||||
- .env
|
|
||||||
Reference in New Issue
Block a user