सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
env_reader एक Dart पैकेज है जो .env फ़ाइल से पढ़ने, एन्क्रिप्ट करने या उन्हें बनाने के माध्यम से वातावरण चर के सुरक्षित निर्देशात्मक तरीके से प्रबंधन की अनुमति देता है। इसके द्वारा इन चर को एक अप्रकट डार्ट मॉडल में बदला जाता है, जिससे संवेदनशील डेटा के खुले होने से रोका जाता है। यह एड्रोइड, आईओएस, वेब, मैकओएस, विंडोज और लिनक्स सहित विभिन्न प्लेटफॉर्मों के लिए डिज़ाइन किया गया है। इस पैकेज को फ्लटर प्रोजेक्ट्स में एक सरल pub add कमांड के माध्यम से बिना किसी दिक्कत के एकीकृत किया जा सकता है। उत्पादन और विकास परिवेशों में कॉन्फ़िगरेशन सुरक्षा को प्राथमिकता देने वाले डेवलपर्स के लिए उपयुक्त है।
उपयोग
API कुंजियों का सुरक्षित प्रबंधन
डेटाबेस प्रमाण-पत्र की रक्षा करना
CI/CD पाइपलाइन में ऐप सीक्रेट्स का प्रबंधन
एन्क्रिप्टेड कॉन्फ़िगरेशन फ़ाइल्स सक्षम करें
परिवेश सेटिंग्स सुरक्षित रूप से साझा करें
पर्यावरण चर उत्पादन को स्वचालित करना
मुख्य विशेषताएँ
.env फ़ाइल्स को सुरक्षित रूप से पढ़ता है
परिवेश चर को एन्क्रिप्ट करता है
अवरोधित Dart मॉडल उत्पन्न करता है
बहु-प्लेटफॉर्म डिप्लॉयमेंट का समर्थन करता है
pub के माध्यम से आसान एकीकरण प्रदान करता है
एन्क्रिप्शन और डिक्रिप्शन उपकरण प्रदान करता है
इनके लिए उपयुक्त
एप्लिकेशन सुरक्षा पर ध्यान केंद्रित विकासकर्मी
पर्यावरण-आधारित कॉन्फ़िगरेशन का उपयोग करने वाली टीमें
गोपनीय प्रबंधन की आवश्यकता वाले परियोजनाएँ
संवेदनशील डेटा वाले Flutter ऐप्स
सुरक्षित वातावरण के हैंडलिंग की आवश्यकता वाले CI/CD वर्कफ़्लो
कई प्लेटफॉर्मों पर डेप्लॉय किए गए ऐप्स
विचार योग्य बातें
सही एन्क्रिप्शन कुंजी प्रबंधन की आवश्यकता होती है
प्रारंभिक सेटअप में कॉन्फ़िगरेशन चरण शामिल होते हैं
ओब्फस्केशन पूर्ण एन्क्रिप्शन की जगह नहीं ले सकता है
अत्यधिक गतिशील रनटाइम सीक्रेट्स के लिए उपयुक्त नहीं
बाहरी .env फ़ाइल की उपस्थिति पर निर्भर करता है
अतिरिक्त बिल्ड प्रक्रिया के चरणों की आवश्यकता हो सकती है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Env Reader
Read, encrypt, or generate environment variables from .env file into an obfuscated Dart model.
Features 🚀
Automated Generation: Transform your .env files into dynamic Dart models directly. No need to add annotation. ✨
Seamless Integration: Directly update your pubspec.yaml and .gitignore on command. No need manual labor. 🛠️
Fortified Encryption: Shield your precious .env configurations with an encryption. Say no to prying eyes.🔒
Data Diversity Unleashed: Whether they're integers, decimals, booleans, or strings. Automatic interpretation is at your service. 🎮
Versatile Sourcing: Load your .env from various sources: assets, files, memory, network, and strings. The choice is yours. 🔄
Install 🚀
Get started with these quick commands:
🔥 Add env_reader to your pubspec.yaml with a single line:
dart pub add env_reader
✨ Unlock the magic by activating the env_reader CLI:
dart pub global activate env_reader
Usage 🚀
Now elevate your development experience with these straightforward steps:
1. Set up your configuration
Start by crafting your .env file in the root directory of your project, right alongside your trusty pubspec.yaml.
[!NOTE]
output: .env successfully generated into lib/src/env_model.dart 🎉
3. Loading your .env
Load the env_reader instance:
import'package:env_reader/env_reader.dart';
import'package:flutter/services.dart';
awaitEnv.load(
EnvStringLoader(await rootBundle.loadString('assets/env/.env')),
"MyOptionalSecretKey");
// Or you can load by creating your own `EnvReader` instance.EnvReader production = EnvReader();
await production.load(
EnvStringLoader(await rootBundle.loadString('assets/env/.env')),
"MyOptionalSecretKey");
4. Access your configuration
To get and read the value of your env:
import'package:env_reader/env_reader.dart';
import'package:my_package/src/env_model.dart';
String api = Env.read("API_KEY") ?? "Got'cha 😎";
bool debug = Env.read<bool>("DEBUG") ?? false;
// If you make your own instance, call it like thisString api = production.read("API_KEY") ?? "Got'cha 😎";
bool debug = production.read<bool>("DEBUG") ?? false;
Text(
text:
debug ? "🤫 pssst, this is my api key y'all \n\n $api" : "Nothing to see here 🤪",
);
// Or you can access the value directly from env generated model earlierText(
text:
EnvModel.debug ? "🤫 pssst, this is my api key y'all \n\n ${EnvModel.apiKey}" : "Nothing to see here 🤪",
);
Env Reader Command 🚀
Available commands:
Flag
Description
-i, --input (mandatory)
Input path of the .env file
-o, --output
Output path for the encrypted .env file
-s, --key
Secrey key for encryption & decryption
--model
Generate dart model file to your desired file path