D
DevOps & CI/CDMedium30 XP4 min read

How do you implement feature flags in Flutter?

TL;DR: Use Firebase Remote Config for server-driven feature flags: define flags in the console, fetch at app launch, use values to gate features. This enables gradual rollout, A/B testing, and kill switches without app store updates.

Full Answer

Feature flags decouple deployment from release. Ship code anytime, but gate it behind a flag — enable it for 1% of users, then 10%, then 100%. Roll back instantly if something breaks.

Firebase Remote Config

  • Define flags in Firebase Console (key-value, with default values)
  • Fetch and activate at app launch (or periodically)
  • Use Riverpod/BLoC to expose flag values to UI
  • Conditional logic: if (flags.isNewSearchEnabled) → show new search UI
🎯

Always define local defaults for all flags. If Remote Config fetch fails (no internet), your app falls back to defaults gracefully — no null crashes.

Code Examples

dartFirebase Remote Config feature flags
Output
// prod: minimumFetchInterval = 1h (cache Remote Config)
// dev: minimumFetchInterval = 0 (always fresh)
// Defaults: never crash if Remote Config is unavailable

Common Mistakes

  • No local defaults — app crashes if Remote Config is unreachable (no internet on first launch)
  • Setting minimumFetchInterval to 0 in production — hits Remote Config quota limits and slows app

Interview Tip

💡

Feature flags + gradual rollout is a key SRE practice. Mention: 1% → 10% → 50% → 100% rollout with monitoring at each step. This shows you understand production reliability, not just feature development.

#feature-flags#remote-config#A/B-testing#rollout