remote_config_gen 0.0.2 copy "remote_config_gen: ^0.0.2" to clipboard
remote_config_gen: ^0.0.2 copied to clipboard

A tool to generate type-safe remote config classes based on the Firebase Remote Config template

Remote Config Generator #

A tool to generate Dart classes from a Firebase Remote Config templates for type safe and static typing. No more hardcoded values!

Usage #

  1. Add the dev_dependency

    dev_dependencies:
        remote_config_gen: 0.0.2
    
  2. Download/Fetch the remoteconfig.template.json for your project

    firebase remoteconfig:get -o remoteconfig.template.json
    
  3. Create a remote_config_gen.yaml file and define the configuration:

    input: remoteconfig.template.json
    output: lib/generated
    
  4. Run the generator

    dart run remote_config_gen
    
  5. Use the generated parameters:

    import 'package:remote_config_gen/remote_config_gen.dart';
    
    // It will return either the remote value or the default defined in the template
    int value = RemoteConfigParams.maxRetryCount.getValue();
    
    // It also accepts remote config groups
    bool isDark = RemoteConfigParams.uiSettings.darkMode.getValue();
    
  6. (Optional) Change values in the template and update Firebase Remote Config

    firebase deploy --only remoteconfig
    

    Note: you can also manually do the changes in the Firebase dashboard and sync the changes again

Observing value changes #

The generated RemoteConfigParam includes a method that returns a Stream, allowing you to observe Remote Config changes while the app is running.

RemoteConfigParams.uiSettings.darkMode.observeValue().listen((bool isDarkMode) {
    // Change the UI based on the new value
});

Limitations #

The same limitations as Firebase Remote config applies. Meaning, you can only use the following types:

  • String
  • Boolean
  • Numbers (int/double)
  • JSON: a JSON string formatted value. It will be returned as String, you need to do the conversion yourself.
1
likes
150
points
115
downloads

Publisher

verified publisherpibi.studio

Weekly Downloads

A tool to generate type-safe remote config classes based on the Firebase Remote Config template

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

dart_style, path, yaml

More

Packages that depend on remote_config_gen