Skip to content

Instantly share code, notes, and snippets.

@Sovann72
Last active February 12, 2024 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sovann72/6ead4b3969bf5b3935004ac30f32edc5 to your computer and use it in GitHub Desktop.
Save Sovann72/6ead4b3969bf5b3935004ac30f32edc5 to your computer and use it in GitHub Desktop.

Follow the documentation here. In your pubspec don't forget to add assets property. My folder structure is

  • /
    • bin
      • env_testing
        • env_testing.dart
    • env
      • dev.env
      • stag.env

So the path in assets would be

...
assets:
  - env/dev.env
  - env/stag.env
import 'dart:io';
import 'package:dotenv/dotenv.dart';
void main() {
final env = DotEnv(includePlatformEnvironment: false)..load(['env/stag.env']);
print(env['BASE_API']);
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment