Coder Social home page Coder Social logo

zujaj / envify_demo Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 119 KB

Demonstrates the Implementation of Envify Package in Flutter.

Kotlin 0.37% Swift 1.17% Objective-C 0.11% Dart 13.20% HTML 11.38% CMake 22.99% C++ 48.66% C 2.12%
flutter flutter-app flutter-environments flutter-demo flutter-web-example flutter-apps flutter-security environment-variables

envify_demo's Introduction

Envify - Your Secret Vault in Flutter

Envify - Your Secret Vault in Flutter

As a Flutter Developer, there comes a time when you need to specify some confidential information in your source code such as API Keys, File Paths, URLs, Client-Side Secret Key etc, so the question arises that how would you:

โœ”๏ธ Keep this data confidential.

๐Ÿ’‰ Integrate it without disclosing it inside the source code.

๐Ÿ›ก๏ธ Protect it if a hacker dismantles the code.

To get into more details, read the medium article.

Project Structure

envify_demo
โ”œโ”€ lib
โ”‚  โ”œโ”€ config 
โ”‚  โ”‚  โ””โ”€ env.dart // The Confidential Information.
โ”‚  โ”‚  โ””โ”€ env.g.dart // The Generated File.
โ”‚  โ”œโ”€ page
โ”‚  โ”‚  โ””โ”€ envify_demo.dart // The Demo Page.
โ”‚  โ”œโ”€ main.dart
โ”œโ”€ pubspec.lock
โ”œโ”€ pubspec.yaml
โ”œโ”€ README.md
โ”œโ”€ .env // The Environment File.

Getting Started

  1. Add the envify package in the pubspec.yaml file.

    dependencies:
        flutter:
        sdk: flutter
        # A better way to handle environment variables using `.env` file.
        envify: ^2.0.2
    
    dev_dependencies:
        
        # A build system for Dart code generation and modular compilation.
        build_runner: ^2.1.5
    
        # A code generator for envify.
        envify_generator: ^2.0.2
  2. Add all the files related to envify in the .gitignore file.

    # Some files to ignore.....
    
    # Envify related 
    .env
    env.dart
    env.g.dart
  3. Outside the lib folder, create an Environment file.

    API_KEY = 'PWEP198104102HEWFUQ'
    SITE_KEY = '91310!@31rwd2PZECAA'
    CLIENT_SECRET = 'XXXAd0q39e20q'
    CLIENT_ID = 'John Doe'
  4. Under the config folder, create an env.dart file

    import 'package:envify/envify.dart';
    part 'env.g.dart';
    
    @Envify(name: 'Secret')
    abstract class Secret {
        /// Holds the API_KEY.
        static const api_key = _Secret.api_key;
    
        /// Holds the SITE_KEY.
        static const site_key = _Secret.site_key;
    
        /// Holds the CLIENT_SECRET.
        static const client_secret = _Secret.client_secret;
    
        /// Holds the CLIENT_ID.
        static const client_id = _Secret.client_id;
    }
  5. Generate the env.g.dart using the below command from the terminal.

    flutter pub run build_runner build --delete-conflicting-outputs

FINAL RESULT

Demonstration of App Using Envify on Windows.

TOOLS & LANGUAGE

envify_demo's People

Contributors

zujaj avatar

Stargazers

 avatar

Watchers

 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.