flutter_config 1.0.4
flutter_config: ^1.0.4 copied to clipboard
Plugin that exposes environment variables to your Dart code in Flutter as well as to your native code in iOS and Android. Bring some 12 factor love to your Flutter apps
Config Variables for your Flutter apps #
Plugin that exposes environment variables to your Dart code in Flutter as well as to your native code in iOS and Android.
Inspired by react-native-config
Basic Usage #
Create a new file .env
in the root of your Flutter app:
API_URL=https://myapi.com
FABRIC_ID=abcdefgh
load all environment varibles in main.dart
import 'package:flutter_config/flutter_config.dart';
void main() async {
await FlutterConfig.loadEnvVariables();
runApp(MyApp());
}
Now you can access your environment varibles anywhere in your app.
import 'package:flutter_config/flutter_config.dart';
FlutterConfig.get('FABRIC_ID') // returns 'abcdefgh'
Keep in mind this module doesn't obfuscate or encrypt secrets for packaging, so do not store sensitive keys in .env
. It's basically impossible to prevent users from reverse engineering mobile app secrets, so design your app (and APIs) with that in mind.
Getting Started #
Install the latest version of the plugin
Refer to Android Setup Guide for initial setup and advanced options
No additional setup is required for iOS, however, for advanced usage refer to the iOS Setup Guide