Remote Config Gist 🚀
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.
Features ✨
- 🔄 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
Installation 📦
Add to your pubspec.yaml
:
dependencies:
remote_config_gist: ^1.0.0
Quick Start 🚀
- 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);
Advanced Usage 🔥
Type-Safe Config Keys
class AppConfig {
static const String welcomeMessage = 'welcome_message';
static const String isFeatureEnabled = 'is_feature_enabled';
static const String themeColor = 'theme_color';
}
Fetch with Options
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);
Status Tracking
RemoteConfigStatus status = config.lastFetchStatus;
DateTime? lastFetch = config.lastFetchTime;
Cache Management
// Clear cache
await config.clearCache();
Best Practices 💡
- Always provide default values
- Handle fetch failures gracefully
- Use type-safe config keys
- Set appropriate fetch intervals
- Monitor fetch status
Configuration Structure 📝
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
}
}
Error Handling ⚠️
try {
await config.fetchConfig();
await config.activate();
} catch (e) {
print('Config fetch failed: $e');
// Handle error - will use cached/default values
}
License 📄
This project is licensed under the MIT License - see the LICENSE file for details.
Support ❤️
If you find this package helpful, please give it a ⭐️ on GitHub!
Alternatives 🔄
- Firebase Remote Config: More features, but requires Firebase setup
- AppConfig: Local-only configuration
- Feature Flags services: More complex feature flag management
Libraries
- remote_config_gist
- A Flutter package for managing remote configuration using GitHub Gists.