Introduction

The koolbase_flutter Flutter package provides a ready‑made SDK for many backend services such as feature flags, remote configuration, authentication, storage, realtime data, OTA updates, and code‑push. If your Flutter project needs networking and API utilities without reinventing the wheel, this package can be a solid starting point.

When to Use the koolbase_flutter Flutter package

Consider adding koolbase_flutter when you:

  • Need a unified API for feature‑flag management or remote configuration.
  • Want built‑in support for authentication and secure storage.
  • Prefer a single dependency that handles OTA updates and code‑push.
  • Are building a clean architecture and can isolate third‑party calls behind a service layer.

It is less suitable if you already have a custom backend SDK or if you need fine‑grained control over every network request.

Installation

Add the package to your pubspec.yaml with the official Flutter CLI command:

Code
flutter pub add koolbase_flutter

After the command finishes, run flutter pub get to fetch the dependency.

Basic Usage Example

Below is a minimal, runnable example that demonstrates how to initialise the SDK, fetch a remote configuration value, and toggle a UI element based on a feature flag.

Dart / Flutter
import 'package:flutter/material.dart';
import 'package:koolbase_flutter/koolbase_flutter.dart';

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

  // Initialise the Koolbase SDK. Replace the placeholder with your actual API key.
  await Koolbase.initialize(
    apiKey: 'YOUR_KOOLBASE_API_KEY',
    // Optional: enable debug logging during development.
    enableDebug: true,
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Koolbase Demo',
      home: const FeatureDemoPage(),
    );
  }
}

class FeatureDemoPage extends StatefulWidget {
  const FeatureDemoPage({Key? key}) : super(key: key);

  @override
  State createState() => _FeatureDemoPageState();
}

class _FeatureDemoPageState extends State {
  bool _isFeatureEnabled = false;
  String _welcomeMessage = 'Loading...';

  @override
  void initState() {
    super.initState();
    _loadRemoteConfig();
  }

  Future _loadRemoteConfig() async {
    try {
      // Fetch a remote config value (e.g., a welcome message).
      final config = await Koolbase.remoteConfig.getValue('welcome_message');
      // Check a feature flag named "new_home_screen".
      final flag = await Koolbase.featureFlags.isEnabled('new_home_screen');

      setState(() {
        _welcomeMessage = config ?? 'Welcome!';
        _isFeatureEnabled = flag ?? false;
      });
    } catch (e) {
      // In a real app, handle errors gracefully.
      setState(() {
        _welcomeMessage = 'Failed to load config.';
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Koolbase Demo')),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text(_welcomeMessage, style: const TextStyle(fontSize: 20)),
            const SizedBox(height: 20),
            _isFeatureEnabled
                ? const Text('🚀 New Home Screen is ENABLED')
                : const Text('🛠️ New Home Screen is DISABLED'),
          ],
        ),
      ),
    );
  }
}

This example assumes the following API surface exists in the package:

  • Koolbase.initialize – boots the SDK.
  • Koolbase.remoteConfig.getValue – retrieves a remote config string.
  • Koolbase.featureFlags.isEnabled – checks a boolean feature flag.

Tip: Keep all SDK calls inside a dedicated service class (e.g., KoolbaseService) so that your UI layer depends only on your own abstractions. This makes future migrations easier.

Setup Notes and Common Pitfalls

  • API key management: Never hard‑code production keys. Use flutter_dotenv or a secure secret manager.
  • Platform-specific configuration: Some features (e.g., OTA updates) may require additional native setup on Android (manifest entries) or iOS (Info.plist). Consult the package README for platform‑specific steps.
  • Version enforcement: The SDK can enforce minimum app versions. Test this flow on a device with an older version to ensure the user experience is graceful.
  • Error handling: Network failures return exceptions. Wrap calls in try/catch and surface user‑friendly messages.
  • Dependency compatibility: Verify that the package version aligns with your Flutter SDK version. Incompatible versions can cause build failures.

Frequently Asked Questions

  • Q: Does koolbase_flutter work with Flutter web?

    A: The package is primarily targeted at mobile (iOS & Android). Web support is not guaranteed; check the pub.dev page for the latest platform matrix.

  • Q: How do I test feature flags locally?

    A: Use the SDK’s sandbox mode (if available) or mock the Koolbase.featureFlags service in your unit tests. The package documentation provides a MockFeatureFlags example.

  • Q: Can I use the SDK without remote config?

    A: Yes. Initialise the SDK and only call the APIs you need (e.g., authentication or storage). Unused modules do not add runtime overhead.

  • Q: What should I do if the SDK throws a version‑enforcement error?

    A: Show a dialog prompting the user to update via the app store. The SDK typically provides a Koolbase.versionEnforcer helper that returns the required version and update URL.

  • Q: Where can I find the full API reference?

    A: The official API docs are hosted on the package’s pub.dev page: https://pub.dev/packages/koolbase_flutter. Always refer to the version‑specific documentation for accurate method signatures.

Frequently Asked Questions

Does koolbase_flutter support Flutter web?

The package is primarily built for iOS and Android. Web support is not guaranteed, so check the pub.dev page for the latest platform compatibility matrix.

How can I test feature flags without a live backend?

Use the SDK's sandbox mode (if provided) or mock the feature‑flag service in unit tests. The documentation includes a MockFeatureFlags example.

Is it safe to use koolbase_flutter for production apps?

Yes, after you review the package's version compatibility, perform a security audit of the API key handling, and test all critical flows. Always keep the package up to date.

What should I do when the version‑enforcement feature blocks the app?

Display an update dialog that links to the appropriate app‑store page. The SDK usually provides a helper that returns the required version and update URL.

Where can I find the full documentation and changelog?

All official docs, API reference, and changelog are available on the pub.dev page: https://pub.dev/packages/koolbase_flutter.