🚀 Feature Flags Flutter SDK

Lightweight, fast, self-hosted feature flag SDK for Flutter apps. Toggle features remotely without rebuilding your app.

Works with the Feature Flags Backend + Dashboard you built.


✨ Features

  • 🔑 API key based authentication
  • ⚡ Fast flag fetch
  • 💾 Local cache & offline fallback
  • 🔁 Auto refresh (polling)
  • 🧠 Simple API (isEnabled)
  • 🧩 Works with any Flutter app
  • 🌍 Supports multiple environments
  • 🔒 Secure (hashed keys, no secrets stored)
  • 🚀 Production ready

📦 Installation

Add to pubspec.yaml:

dependencies:
  feature_flags: 0.0.1

or (local development):

dependencies:
  feature_flags:
    path: ../feature_flags

🚀 Quick Start

1️⃣ Initialize SDK

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await FeatureFlags.init(
    apiKey: "YOUR_API_KEY",
  );

  runApp(MyApp());
}

2️⃣ Use flags anywhere

if (FeatureFlags.isEnabled("new_home")) {
  return NewHome();
} else {
  return OldHome();
}

🔄 Live updates

Flags are refreshed automatically (every 30s by default).

To manually rebuild UI:

setState(() {});

or any state management packages that u prefer


🧠 Fallback values

FeatureFlags.isEnabled("new_home", fallback: false);

📴 Offline support

If network fails:

  • last known flags are used
  • app never crashes
  • perfect for production

⚙️ Configuration

Change refresh interval

await FeatureFlags.init(
  apiKey: "...",
);

🔒 Security model

  • SDK uses API keys, not JWT
  • Keys are scoped to environment
  • Backend stores only hashed keys
  • Raw keys shown only once
  • Safe to ship in production apps

🧩 Example

Text(
  FeatureFlags.isEnabled("new_home")
    ? "New UI"
    : "Old UI",
);

🛑 Dispose (optional)

FeatureFlags.dispose();

🧠 Roadmap

  • Stream updates (no rebuild)
  • Widget builder
  • Percentage rollout
  • User targeting
  • Android SDK
  • iOS SDK
  • React SDK
  • Web SDK

🏆 Why this exists

This SDK is:

  • fast
  • simple
  • self-hosted
  • cheap - free for now
  • perfect for indie apps & startups

👨‍💻 Author

Built with ❤️ by Charan If you use this in production, ⭐ star the repo!

Libraries

feature_flag_sdk