Sitemap
Go With Flutter

Flutter Tips & Tricks.

Member-only story

DotEnv In Flutter

--

Press enter or click to view image in full size

DotEnv .envlet you manage environment variables and load them from a .env file. It actually store sensitive information like API keys, database URLs, and other configuration settings without hardcoding them in your Flutter code. Moreover, it protects your keys, URLs and sensitive keys or IDs from exposure as we always tend to use BitBucket, GitHub, GitLab, etc. for version control.

DotEnv .env is needed in these following scenarios:

→ APIs Keys,
→ URLs,
→ App IDs,
→ Encoded Strings,
→ Credentials,
→ Environment-Specific Values,
→ Configuration Settings, etc.

Advantages of using .env in Flutter

  1. Security
  2. Code Reusability
  3. Ease of Deployment
  4. Configuration Management
  5. Flexibility and Easy

Implementation of .env flutter_dotenv

  1. Install flutter_dotenv in pubspec.yaml file.
flutter_dotenv: ^5.1.0

2. Create .env file in the root project folder.

3. Import that file in assets section in pubspec.yaml file.

--

--

Lakshydeep Vikram
Lakshydeep Vikram

Written by Lakshydeep Vikram⁠

Software Developer | Google Dev Library Author | Flutter Enthusiast