masamune_model_firebase_remote_config 3.2.6 copy "masamune_model_firebase_remote_config: ^3.2.6" to clipboard
masamune_model_firebase_remote_config: ^3.2.6 copied to clipboard

unlisted

Package that allows remote configurations to be retrieved as a Masamune framework documentation model.

Masamune logo

Masamune Model Firebase Remote Config

Follow on GitHub Follow on X Follow on YouTube Maintained with Melos

GitHub Sponsor


[GitHub] | [YouTube] | [Packages] | [X] | [LinkedIn] | [mathru.net]


Masamune Model Firebase Remote Config #

Usage #

Installation #

  1. Add the package to your project.
flutter pub add masamune_model_firebase_remote_config

Run flutter pub get after editing pubspec.yaml manually.

Setup #

  1. Register the adapter with your Masamune model configuration. Provide default values and fetch intervals.
// lib/main.dart

import 'package:masamune_model_firebase_remote_config/masamune_model_firebase_remote_config.dart';

final modelAdapter = FirebaseRemoteConfigModelAdapter(
  options: DefaultFirebaseOptions.currentPlatform,  // Firebase config
  initialValue: {
    "feature_enabled": false,
    "api_endpoint": "https://api.example.com",
    "max_items": 10,
  },
  minimumFetchInterval: Duration(minutes: 30),  // Cache duration
);

void main() {
  runMasamuneApp(
    appRef: appRef,
    modelAdapter: modelAdapter,
    (appRef, _) => MasamuneApp(
      appRef: appRef,
      home: HomePage(),
    ),
  );
}

Load Remote Config Values #

  1. Load the remote config as a Masamune model. Fetching is handled automatically through fetchAndActivate() each time the adapter loads.
class MyPage extends PageScopedWidget {
  @override
  Widget build(BuildContext context, PageRef ref) {
    // Load remote config as a document
    final config = ref.app.model(
      FirebaseRemoteConfigModel.document(),
    )..load();

    return Scaffold(
      body: Column(
        children: [
          // Access config values
          Text("Feature: ${config.value.get<bool>("feature_enabled")}"),
          Text("Endpoint: ${config.value.get<String>("api_endpoint")}"),
          Text("Max Items: ${config.value.get<int>("max_items")}"),
        ],
      ),
    );
  }
}

Important Notes #

Read-Only: Only read operations are supported. Saving or deleting documents with this adapter throws UnsupportedError. Use Firebase Console or the Remote Config REST API to update values.

Caching: The adapter respects minimumFetchInterval. Values are cached and won't be refetched until the interval expires.

Default Values: Provide initialValue to ensure your app works even when remote config is unavailable.

Firebase Console Setup #

  1. Go to Firebase Console → Remote Config
  2. Add parameters matching your initialValue keys
  3. Set values for different conditions (e.g., by platform, version, or user segment)
  4. Publish your changes

GitHub Sponsors #

Sponsors are always welcome. Thank you for your support!

https://github.com/sponsors/mathrunet

0
likes
150
points
295
downloads

Publisher

verified publishermathru.net

Weekly Downloads

Package that allows remote configurations to be retrieved as a Masamune framework documentation model.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

firebase_remote_config, flutter, katana, katana_firebase, masamune, meta

More

Packages that depend on masamune_model_firebase_remote_config