loadFile method
Load from a .env file path (mobile/desktop/CLI only).
Example: await env.loadFile('.env');
If overrideExisting is false, existing keys are preserved.
Implementation
Future<void> loadFile(
String filePath, {
bool overrideExisting = true,
bool expand = true,
}) async {
if (kIsWeb) {
_logger.warn(
'loadFile("$filePath") ignored on Web. Use loadAsset() instead.',
);
return;
}
final contents = await platform.readFile(filePath);
final parsed = _parse(contents);
_merge(parsed, overrideExisting: overrideExisting);
if (expand) _expandAll();
_logger.info('Loaded ${parsed.length} keys from "$filePath".');
}