Usually in an application it is necessary to have at hand a system to manage global variables (or environment variables) to propagate inside the application. env_manager does just that, it manages your environment variables in a smart way.

How it works

Your environment variables are stored in a folder called envdir, this folder will contain all of your environment variable files and you can divide them up as you see fit.

Below is an example of a project folder that uses env_manager.

│	└───example_env_file_inside_folder.yaml

Setup the package in your application

Add the package in the dependecies section of your pubspec.yaml file.

env_manager: ^0.1.2

and execute the flutter pub get to fetch the package from

After the fetch, execute the flutter pub run env_manager:make to create the envdir in your project root directory, inside this folder your can create all your environment files (even with different folders).

IMPORTANT: All environment files must use the following format

	example_A_variable: "My A variable in production"
	example_B_variable: "My B variable in prodution"

	example_A_variable: "My A variable in development"
	example_B_variable: "My B variable in development"

All variables must be the same for production and development sections.

After this, you need to add the environment files in the assets section inside the pubspec.yaml file.

		- assets/myexampleimage.png
		- assets/anotherexampleimage.jpg

		#Env Files
		- envdir/application.yaml
		- envdir/example_folder/new_env_file.yaml

Add the code in your application

In your main class, add the following snippt before the runApp method

void main() async {

	await env.locateAndLoad([
		env.EnvironmentFileLoader("myEnvName", await rootBundle.loadString("envdir/application.yaml")),
		env.EnvironmentFileLoader("myEnvName2", await rootBundle.loadString("envdir/example_folder/new_env_file.yaml")),
		..other files to load..


You can also setup the environment to reply with production variables or with development variables using

env.useProductionEnvironment(true | false);

IMPORTANT: By default is set to false

or you can call directly the environment using the get method (By default will take the useProductionEnvironment value)

env.get("myEnvName", withProduction: true | false)["variable_name"]