Code Monkey home page Code Monkey logo

common_configs's Introduction

Common configs

A simple package which can be used as a global config in your app or you can share configs with your packages.

Features

  • Use as a global configs across your app.
  • Share configs with packages.
  • Access config from anywhere.
  • Load configs from a Map with [Config.fromMap].

Getting started

Add this package as a dependency

dart pub add common_configs

and import in your file by adding the below statement

import 'package:common_configs/common_configs.dart';

Usage

A short example.

Use anything to use as an identifier for your config's type. In this example, I'm using an enum ConfigType.

enum ConfigType {
  devel,
  staging,
  prod,
}

We'll use a pre-existing MapConfig which uses Map<String, dynamic> as a Config with an identifier.

Config createDevelConfig() => MapConfig(ConfigType.devel, { 'hello': 'world' });

To create your own config, start by extending the [Config].

To use this config, set it by using [Config.put].

Config.put(create: createDevelConfig);

By default, configs are stored by the name default.

To use a another name, you can use the name parameter when getting or setting a config.

Config.put(create: createDevelConfig, name: 'app.config');

Additional information

You can write your own code to obtain configuration details from a source like a json, or .env file.

For a longer example, check out the /example folder.

common_configs's People

Contributors

predatorx7 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.