Environments
Environments isolate your configuration, data, and users across production, staging, and development — each with its own API keys.
Overview
Every Koolbase project has one or more environments. Each environment is a completely isolated context — it has its own:
Changes made in one environment never affect another. Your production users are always isolated from staging and development activity.
Recommended Setup
Most teams use three environments:
pk_live_...Live users and real data. Feature flags are carefully controlled. Version enforcement is active. Treat this environment with care.
pk_live_...Pre-release testing environment. Mirrors production config but with test data. Use this to validate changes before going live.
pk_live_...Local development. All flags can be freely toggled. No real users. Safe to experiment without risk.
API Keys
Each environment has two keys:
pk_live_...Public KeyUsed in your Flutter app. Safe to include in client-side code. Used with Koolbase.init().
sk_live_...Secret KeyUsed for server-side API calls. Never expose this in client code or commit it to version control.
Key rotation
Using Environments in Flutter
Pass the correct key for each build flavor using Dart environment variables or a config file:
import 'package:flutter/material.dart';
import 'package:koolbase/koolbase.dart';
// Define keys per environment
const koolbaseKeys = {
'production': 'pk_live_prod_key_here',
'staging': 'pk_live_staging_key_here',
'development': 'pk_live_dev_key_here',
};
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Use --dart-define=ENV=production to switch environments
const env = String.fromEnvironment('ENV', defaultValue: 'development');
final apiKey = koolbaseKeys[env] ?? koolbaseKeys['development']!;
await Koolbase.init(apiKey: apiKey);
runApp(const MyApp());
}Run with a specific environment:
# Development (default)
flutter run
# Staging
flutter run --dart-define=ENV=staging
# Production build
flutter build apk --dart-define=ENV=productionDuplicating Environments
From the dashboard you can duplicate an existing environment. This copies all feature flags, flag rules, remote config values, and version policies into a new environment with fresh API keys.
This is useful when setting up a new staging environment that mirrors your current production config, or when creating a demo environment for testing.