Skip to main content

smf_firebase_remote_config 0.9.0 copy "smf_firebase_remote_config: ^0.9.0" to clipboard
smf_firebase_remote_config: ^0.9.0 copied to clipboard

The SMF module of Firebase Remote Config for the Flutter app that SMF generates. The app reads values that the Firebase project changes without a new version of the app.

example/README.md

Generate a Flutter app that reads Firebase Remote Config #

firebase_remote_config is the module of the SMF CLI with which the app reads values of remote config from Firebase Remote Config. Choose it with -m:

dart pub global activate smf_flutter_cli
smf create my_app -m firebase_remote_config --no-input

Firebase Remote Config works on the Firebase app, so smf create adds the module that sets up Firebase:

Adding firebase_core: a dependency of firebase_remote_config.
Adding flutter_core: the only provider of the app entry role, which every app needs.

The module adds firebase_remote_config to the pubspec.yaml of the app, and lib/core/remote_config/firebase_remote_config_service.dart with the remote config service on FirebaseRemoteConfig. The remote config role adds lib/core/remote_config/app_remote_config.dart with appRemoteConfig, which the rest of the app uses, and lib/core/remote_config/remote_values.dart with RemoteValues. bootstrap() starts remote config before the first frame, once Firebase started, and waits at most a second for the values that the device kept:

Future<void> bootstrap() async {
  await Firebase.initializeApp(options: firebaseOptionsOfFlavor);
  await initRemoteConfig();
}

A parameter has a default in RemoteValues.defaults and a getter, which the modules of the app give the role. To add one of your own, such as a text of a banner, put it into lib/core/remote_config/remote_values.dart:

static const Map<String, Object> defaults = {'banner_text': ''};

/// The text of the banner of the home screen; empty for none.
String get bannerText => _values['banner_text']! as String;

Then create banner_text as a String in Remote Config of the Firebase project of each flavor. A widget follows the value, which changes once you publish a new one:

ValueListenableBuilder<RemoteValues>(
  valueListenable: appRemoteConfig,
  builder: (context, values, _) => values.bannerText.isEmpty
      ? const SizedBox.shrink()
      : Text(values.bannerText),
);

The documentation has more on the firebase_remote_config module.

0
likes
160
points
0
downloads

Documentation

Documentation
API reference

Publisher

verified publishersaymyframe.com

Weekly Downloads

The SMF module of Firebase Remote Config for the Flutter app that SMF generates. The app reads values that the Firebase project changes without a new version of the app.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#flutter #firebase #remote-config #feature-flags #template

License

Apache-2.0 (license)

Dependencies

mason, smf_contracts, smf_firebase_core

More

Packages that depend on smf_firebase_remote_config