A lightweight and easy-to-use Flutter package for remote configuration using GitHub Gists. Perfect for small to medium-sized apps that need remote configuration without the complexity of Firebase.
- 🔄 Dynamic configuration updates
- 🔒 Type-safe configuration access
- ⚡️ Automatic caching mechanism
- ⏱️ Configurable fetch intervals
- 🌐 Offline support with fallback values
- 🎯 Zero external dependencies (except http)
- 📱 Cross-platform support
Add to your pubspec.yaml
:
dependencies:
remote_config_gist: ^1.0.0
- Create a GitHub Gist with your config:
{
"welcome_message": "👋 Welcome to My App!",
"is_feature_enabled": true,
"theme_color": "#2196F3"
}
- Initialize in your app:
final config = RemoteConfigGist(
gistId: 'your_gist_id_here',
filename: 'config.json',
defaultConfig: {
'welcome_message': 'Welcome!',
'is_feature_enabled': false,
'theme_color': '#000000',
},
);
// Fetch and activate
await config.fetchConfig();
await config.activate();
- Use the config values:
String message = config.getValue<String>('welcome_message', 'Default');
bool isEnabled = config.getValue<bool>('is_feature_enabled', false);
class AppConfig {
static const String welcomeMessage = 'welcome_message';
static const String isFeatureEnabled = 'is_feature_enabled';
static const String themeColor = 'theme_color';
}
final config = RemoteConfigGist(
gistId: 'your_gist_id',
filename: 'config.json',
fetchInterval: Duration(hours: 12),
timeout: Duration(seconds: 5),
);
// Force refresh
await config.fetchConfig(forceRefresh: true);
RemoteConfigStatus status = config.lastFetchStatus;
DateTime? lastFetch = config.lastFetchTime;
// Clear cache
await config.clearCache();
- Always provide default values
- Handle fetch failures gracefully
- Use type-safe config keys
- Set appropriate fetch intervals
- Monitor fetch status
Example of a well-structured config:
{
"app_config": {
"version": "1.0.0",
"maintenance_mode": false
},
"feature_flags": {
"show_beta_features": false,
"enable_analytics": true
},
"ui_config": {
"theme_color": "#2196F3",
"font_size": 16
}
}
try {
await config.fetchConfig();
await config.activate();
} catch (e) {
print('Config fetch failed: $e');
// Handle error - will use cached/default values
}
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this package helpful, please give it a ⭐️ on GitHub!
- Firebase Remote Config: More features, but requires Firebase setup
- AppConfig: Local-only configuration
- Feature Flags services: More complex feature flag management