Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lamnhan066/firebase_remote_helper
Helper for firebase remote config
https://github.com/lamnhan066/firebase_remote_helper
flutter plugin
Last synced: about 1 month ago
JSON representation
Helper for firebase remote config
- Host: GitHub
- URL: https://github.com/lamnhan066/firebase_remote_helper
- Owner: lamnhan066
- License: mit
- Created: 2022-07-01T08:23:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-16T08:47:08.000Z (4 months ago)
- Last Synced: 2024-09-30T12:04:43.944Z (about 2 months ago)
- Topics: flutter, plugin
- Language: Dart
- Homepage:
- Size: 58.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Firebase Remote Helper
This plugin makes it easier for you to use firebase remote config.
## Usage
Await for the initialization:
``` dart
// Get the instance
final remoteHelper = FirebaseRemoteHelper.instance;// Initialize
await remoteHelper.initial(
fetchTimeout: const Duration(seconds: 3), // Optional: default is 1 minute
minimumFetchInterval: const Duration(minutes: 60), // Optional: default is 60 minutes
defaultParameters: {
'bool': true,
'int': 5,
'String': 'This is string',
'mapInt': {'a': 1, 'b': 2},
'mapString': {'a': 'a', 'b': 'b'},
'mapBool': {'a': true, 'b': false},
'listInt': [1, 2, 3],
'listString': ['a', 'b', 'c'],
'listBool': [true, false, true],
}, // Optional: default is not set
);
```Or you can call initial and await for it later:
``` dart
// Initialize
remoteHelper.initial();// And wait for the initial later
await remoteHelper.ensureInitialized;
```**NOTE:** You should provide default values for all used parameters to avoid issues.
Get value as specific `type`:
``` dart
/// Number:
/// Example value on firebase: 1
remoteHelper.getInt('key');/// Boolean:
/// Example value on firebase: true/false
remoteHelper.getBool('key');/// Number:
/// Example value on firebase: 1.0
remoteHelper.getDouble('key');/// String:
/// Example value on firebase: "something"
remoteHelper.getString('key');/// JSON as List:
/// Example value on firebase: ["something", "something other"]
///
/// Only support bool, num, String as return type of list
remoteHelper.getList('key');/// JSON as Map:
/// Example value on firebase: {"someKey": 1, "someKey other": 2}
///
/// Only support bool, num, String as return type of map's values
remoteHelper.getMap('key');
```Get value as `RemoteConfigValue`:
``` dart
/// Return RemoteConfigValue
/// Then you can use .asBool, .asInt, .asDouble, .asString, .asMap, .asList
remoteHelper.get('key');
```