The remote config module delivers key-value pairs from the AppDNA Console to your app. All reads are synchronous from an in-memory cache — they never block the UI thread or require a network call.
Get Config Values
Read values using typed getters with default fallbacks:
final welcome = AppDNA.remoteConfig.getString("welcome_message", defaultValue: "Hello!");
final maxRetries = AppDNA.remoteConfig.getInt("max_retries", defaultValue: 3);
final discount = AppDNA.remoteConfig.getDouble("discount_rate", defaultValue: 0.1);
final promoEnabled = AppDNA.remoteConfig.getBool("show_promo", defaultValue: false);
For complex values, use getJSON:
final bannerConfig = AppDNA.remoteConfig.getJSON("hero_banner");
// Returns Map<String, dynamic>? -- null if key not found
Module Access
final remoteConfig = AppDNA.remoteConfig;
Module Methods
| Method | Signature | Description |
|---|
getString | String getString(String key, {required String defaultValue}) | Get a string value |
getInt | int getInt(String key, {required int defaultValue}) | Get an integer value |
getDouble | double getDouble(String key, {required double defaultValue}) | Get a double value |
getBool | bool getBool(String key, {required bool defaultValue}) | Get a boolean value |
getJSON | Map<String, dynamic>? getJSON(String key) | Get a JSON map |
getAllKeys | List<String> getAllKeys() | List all available config keys |
When Config Refreshes
The SDK refreshes remote config automatically:
- On app launch — if the cached config has expired (default TTL: 5 minutes)
- On return from background — same TTL check
If the fetch fails, the SDK continues using cached values. On first launch with no connectivity, bundled config defaults are used.
The config TTL is configurable via AppDNAOptions(configTTL: 600) (in seconds). The default is 300 seconds (5 minutes).
Listen for Config Changes
class ConfigHandler extends RemoteConfigDelegate {
@override
void onConfigUpdated(List<String> updatedKeys) {
if (updatedKeys.contains("show_promo")) {
final show = AppDNA.remoteConfig.getBool("show_promo", defaultValue: false);
updatePromoBanner(visible: show);
}
}
}
AppDNA.remoteConfig.delegate = ConfigHandler();
Full Example
import 'package:appdna_sdk/appdna_sdk.dart';
import 'package:flutter/material.dart';
class HomeScreen extends StatefulWidget {
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> implements RemoteConfigDelegate {
String _title = "Welcome";
bool _showBanner = false;
String _bannerText = "";
@override
void initState() {
super.initState();
AppDNA.remoteConfig.delegate = this;
_loadConfig();
}
void _loadConfig() {
setState(() {
_title = AppDNA.remoteConfig.getString("home_title", defaultValue: "Welcome");
_showBanner = AppDNA.remoteConfig.getBool("show_promo_banner", defaultValue: false);
_bannerText = AppDNA.remoteConfig.getString("promo_banner_text", defaultValue: "");
});
}
@override
void onConfigUpdated(List<String> updatedKeys) {
_loadConfig();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(_title)),
body: Column(
children: [
if (_showBanner)
MaterialBanner(
content: Text(_bannerText),
actions: [TextButton(onPressed: () {}, child: const Text("Learn More"))],
),
// Rest of the home screen
],
),
);
}
}
Remote config values are managed in the Console under Settings > Remote Config. Changes take effect on the next SDK config refresh.