Skip to content
pubscout

flutter_env_native

0.2.0, released a year ago by mastersam.tech

Makes --dart-define and --dart-define-from-file variables available to native Android and iOS platforms.

WASM-ready
$ flutter pub add flutter_env_native
Source repository

What it does

Provides compile-time environment variables set via Flutter build flags directly to native platform files like Android's build.gradle, manifests, and Kotlin code, as well as iOS plist and Swift files.

AI-written summary of version 0.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need access to dart-define environment variables inside native Android (Gradle/Kotlin/Manifest) or iOS (plist/Swift) code.
  • You want to configure native app names, keys, or endpoints using a .env file passed via --dart-define-from-file.

Skip it when

  • You only need environment variables within Dart code and do not require them on the native side.
  • You cannot make the required native configuration changes in build.gradle, Podfile, or Info.plist.

Strengths

  • Bridges Dart compile-time variables with native Android and iOS configurations.
  • Supports --dart-define and --dart-define-from-file workflows.

Weaknesses

  • Requires manual configuration and modifications to native project files (build.gradle, Podfile, AndroidManifest.xml, Info.plist).
  • iOS xcconfig has limitations with certain characters like '//'.

Setup

Kind
Plugin (native code)
Effort
Medium
Code generation
No
Direct dependencies
0

Requires editing android/app/build.gradle, AndroidManifest.xml, MainActivity.kt, ios/Podfile, and info.plist.

val appName = BuildConfig.APP_NAME

Alternatives

Packages that do the same job and could replace flutter_env_native.

  • flutter_dotenv

    Loads configuration variables from .env asset files or strings into Flutter apps.

  • gtk

    GTK utilities for Flutter Linux applications, providing settings and application lifecycle helpers.

  • flutter_flavorizr

    A utility to easily create and configure application flavors in Flutter.

  • kartal

    Collection of Dart and Flutter extensions for context, primitive variables, and common utilities.