mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 16:30:40 +00:00
Compare commits
3 commits
147e74461a
...
57ea7d00fb
Author | SHA1 | Date | |
---|---|---|---|
|
57ea7d00fb | ||
|
59d94bf1f1 | ||
|
f8b4c7f57f |
3 changed files with 13 additions and 2 deletions
|
@ -24,7 +24,6 @@ class RemoteConfigService {
|
||||||
await remoteConfig.setDefaults(featuresDefaultValues.map((key, value) => MapEntry(key.name, value)));
|
await remoteConfig.setDefaults(featuresDefaultValues.map((key, value) => MapEntry(key.name, value)));
|
||||||
await remoteConfig.activate();
|
await remoteConfig.activate();
|
||||||
await remoteConfig.ensureInitialized();
|
await remoteConfig.ensureInitialized();
|
||||||
unawaited(remoteConfig.fetch());
|
|
||||||
|
|
||||||
log('Firebase remote config initialized successfully');
|
log('Firebase remote config initialized successfully');
|
||||||
} on FirebaseException catch (e) {
|
} on FirebaseException catch (e) {
|
||||||
|
@ -34,6 +33,12 @@ class RemoteConfigService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> fetchConfig() async {
|
||||||
|
// https://github.com/firebase/flutterfire/issues/6196#issuecomment-927751667
|
||||||
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
await FirebaseRemoteConfig.instance.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
dynamic getValue(Feature feature) => FirebaseRemoteConfig.instance.getValue(feature.name).toValue(feature);
|
dynamic getValue(Feature feature) => FirebaseRemoteConfig.instance.getValue(feature.name).toValue(feature);
|
||||||
|
|
||||||
Map<Feature, dynamic> getAll() {
|
Map<Feature, dynamic> getAll() {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lightmeter/data/models/feature.dart';
|
import 'package:lightmeter/data/models/feature.dart';
|
||||||
|
@ -25,7 +26,11 @@ class RemoteConfigProviderState extends State<RemoteConfigProvider> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_updatesSubscription = widget.remoteConfigService.onConfigUpdated().listen(_updateFeatures);
|
widget.remoteConfigService.fetchConfig();
|
||||||
|
_updatesSubscription = widget.remoteConfigService.onConfigUpdated().listen(
|
||||||
|
_updateFeatures,
|
||||||
|
onError: (e) => log(e.toString()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -18,6 +18,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
|
when(() => mockRemoteConfigService.fetchConfig()).thenAnswer((_) async {});
|
||||||
when(() => mockRemoteConfigService.getValue(Feature.unlockProFeaturesText)).thenReturn(false);
|
when(() => mockRemoteConfigService.getValue(Feature.unlockProFeaturesText)).thenReturn(false);
|
||||||
when(() => mockRemoteConfigService.getAll()).thenReturn({Feature.unlockProFeaturesText: false});
|
when(() => mockRemoteConfigService.getAll()).thenReturn({Feature.unlockProFeaturesText: false});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue