- add package
flutter_dotenvto the project. - https://pub.dev/packages/flutter_dotenv - add the
.envto theassetswithin the pubspec.yml - add
*.envto the .gitignore - add the import
import 'package:flutter_dotenv/flutter_dotenv.dart';to the main.dart file and useawait dotenv.load(fileName: ".env");to load the .env file and make sure that the .env file is not empty. - If it was empty or haven't been created at the time it was added to the pubspec.yml go to pubspec.yml again and press ctrl + save
- import the package wherever necessary
import 'package:flutter_dotenv/flutter_dotenv.dart';and usedotenv.env['VAR_NAME'];theVAR_NAMEshould be the same as the one you want to load from the .env file.
-
Notifications
You must be signed in to change notification settings - Fork 0
kirushanth05/posts_app
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published