Mike  Kozey

Mike Kozey

1657732260

ENV_manager: Manage Your Application's Environment with Env_manager

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.

your_project
├───android
│└───...
├───assets
│└───...
├───build
│└───...
│
├───envdir
│├───application.yaml
│├───another_env_file.yaml
│└───example_env_folder
│    └───example_env_file_inside_folder.yaml
│
├───ios
│└───...
├───lib
│└───...
├───test
│└───...
├───.flutter-plugins
├───.flutter-plugins-dependencies
├───.gitattributes
├───.gitignore
├───.metadata
├───.packages
├───analysis_options.yml
├───your_project.iml
├───pubspec.lock
├───pubspec.yaml
└───README.md

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 pub.dev.

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

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

development:
    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.

...
flutter:
    assets:
        - 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 {
    WidgetsFlutterBinding.ensureInitialized();

    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")["variable_name"]
env.get("myEnvName", withProduction: true | false)["variable_name"]

Installing

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add env_manager

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  env_manager: ^0.1.2

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:env_manager/env_manager.dart';

example/main.dart

import 'package:flutter/material.dart';
import 'package:env_manager/env_manager.dart' as env;
import 'package:flutter/services.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await env.locateAndLoad([
    env.EnvironmentFileLoader(
        "myEnvName", await rootBundle.loadString("envdir/application.yaml")),
  ]);

  //Optional
  env.useProductionEnvironment(true);

  runApp(MaterialApp(
    title: env.get("myEnvName")["application_name"],
    home: const MyApplication(),
  ));
}

class MyApplication extends StatefulWidget {
  const MyApplication({Key? key}) : super(key: key);

  @override
  _MyApplicationState createState() => _MyApplicationState();
}

class _MyApplicationState extends State<MyApplication> {
  @override
  void initState() {
    super.initState();

    env.useProductionEnvironment(true);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        alignment: Alignment.center,
        child: Text(env.get("myEnvName")["my_env_variable"]),
      ),
    );
  }
}

Author: Giannuzzoexe
Source Code: https://github.com/giannuzzoexe/env_manager 
License: BSD-3-Clause license

#flutter #dart #managed #env 

What is GEEK

Buddha Community

ENV_manager: Manage Your Application's Environment with Env_manager
Origin Scale

Origin Scale

1616572311

Originscale Order Management System

Originscale order management software helps to manage all your orders across channels in a single place. Originscale collects orders across multiple channels in real-time - online, offline, D2C, B2B, and more. View all your orders in one single window and process them with a simple click.

#order management system #ordering management system #order management software #free order management software #purchase order management software #best order management software

Tech Avidus

Tech Avidus

1604379605

Digital Assets Management Software Solution | AI-based Assets Management System

A Digital Asset Management System makes it easier to store, manage, and share all of your digital assets on cloud-based storage.

We help you to build Digital Asset Management (DAM) systems with your precise business requirements, whether you want one for maintaining management, production management, brand management systems, or implementing with your sales department with the digital assets it needs.

To learn more about how the Digital Asset Management system will help your business, email us at hello@techavidus.com

#digital assets management #assets management solution #digital asset management system #production management #brand management

Revenue Cycle Management Software Services and Custom Integration - SISGAIN

Revenues come day in day out and it becomes strenuous to keep a track of them. With the help of Revenue cycle management software, one is able to perform the hospital revenue cycle management in Oklahoma, USA in a much simplified and easy manner. Our skilful developers and engineers created the healthcare revenue cycle management software that is convenient to use by its users and meets the customers requirement. We happen to be one of the notable revenue cycle management companies, facilitating the needs of our customers and being efficient and useful in performance. For more information call us at +18444455767 or email us at hello@sisgain.com

#revenue cycle management #revenue cycle management software #revenue cycle management companies #hospital revenue cycle management #revenue cycle management services #revenue cycle management solutions

Top Inventory Management Mobile App Development Company

Do you want to know the cost and features to develop an application like Inventory management software? AppClues Infotech is the best mobile app development company that builds custom Inventory management apps for your business.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#develop an inventory management software #inventory management software development #inventory management software development cost #inventory management mobile app development #develop an inventory management application

Origin Scale

Origin Scale

1619083348

Inventory Management Software

Originscale Inventory Management Software help you seamlessly integrates your sales channels and inventory locations to give your team complete and reliable inventory control. TRY FOR FREE Today

#inventory management #inventory management software #inventory management system #manufacturing inventory management #inventory control software #stock inventory management