Skip to content

In this video, we will see how to setup and use environment variables with Flutter. We will not be using any package to handle this.

License

Notifications You must be signed in to change notification settings

playgroundlk/working_with_environment_variables_flutter_by_codefarmer

Repository files navigation

Working with environment variables flutter By Codefarmer

In this video, we will see how to setup and use environment variables with Flutter. We will not be using any package to handle this.

Usage

  • Load environment variables from file.

    flutter run --dart-define-from-file=lib/config/config.json
    
  • Setup VSCode Debugger to autoload the env file. add toolArgs parameters --dart-define-from-file PATH/TO/ENV/FILE to launch.json file.

    {
      // Use IntelliSense to learn about possible attributes.
      // Hover to view descriptions of existing attributes.
      // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
      "version": "0.2.0",
      "configurations": [
        {
          "name": "development",
          "request": "launch",
          "type": "dart",
          "toolArgs": [
            "--dart-define-from-file",
            "lib/env/development.env"
          ]
        },
        {
          "name": "production",
          "request": "launch",
          "type": "dart",
          "flutterMode": "release",
          "toolArgs": [
            "--dart-define-from-file",
            "lib/env/production.env"
          ]
        },
        {
          "name": "working_with_environment_variables_flutter (profile mode)",
          "request": "launch",
          "type": "dart",
          "flutterMode": "profile"
        },
        {
          "name": "working_with_environment_variables_flutter (release mode)",
          "request": "launch",
          "type": "dart",
          "flutterMode": "release"
        }
      ]
    }
    

Resources

Working with environment variables flutter By Codefarmer

Author

I am Programmer

License

This is free and unencumbered software released into the public domain.

About

In this video, we will see how to setup and use environment variables with Flutter. We will not be using any package to handle this.

Topics

Resources

License

Stars

Watchers

Forks