tool_config 0.1.0
tool_config: ^0.1.0 copied to clipboard
Generic configuration management system for Flutter apps (feature flags + remote config + local storage)
tool_config #
Feature flag system with remote configuration support.
Overview #
Provides runtime feature toggles for:
- Module-specific features
- App-level features
- Remote configuration (Firebase)
- Local overrides
Core Concepts #
FeatureName #
Interface for defining feature enums:
enum ChatFeatureName implements FeatureName {
stickers,
quickActions,
}
FeaturesStateContract #
Contract for BLoC states with feature flags:
abstract class ChatState implements FeaturesStateContract {
static List<ChatFeatureName> get supportedFeatureNames => [
ChatFeatureName.stickers,
];
const ChatState({
required List<Feature> features,
});
factory ChatState.initial() => ChatState(
features: supportedFeatureNames
.map((e) => Feature.enabled(e))
.toList(),
);
}
Feature Checking #
// In UI
if (state.isFeatureEnabled(ChatFeatureName.stickers)) {
return StickerButton();
}
// In BlocBuilder
BlocBuilder<ChatBloc, ChatState>(
buildWhen: (prev, curr) => isFeatureChangesCondition(
ChatFeatureName.stickers,
prev,
curr,
),
builder: (context, state) => ...,
)
Feature Flags Repository #
// Fetch features from remote config
final features = await featureFlagsRepository.getFeatures([
ChatFeatureName.stickers,
ChatFeatureName.quickActions,
]);
// Update state
emit(state.copyWith(features: features));
Remote Configuration #
Features can be toggled remotely via Firebase Remote Config without app updates.
See Pattern 2: Module-Specific Feature Flags for complete integration guide.