initialize method
Initialises the provider (e.g. fetch + activate remote config).
Must be called before any getValue call.
Implementation
@override
Future<void> initialize() async {
try {
await _remoteConfig.setConfigSettings(
RemoteConfigSettings(
fetchTimeout: _fetchInterval,
minimumFetchInterval: _minimumFetchInterval,
),
);
await _remoteConfig.fetchAndActivate();
_lastFetchedAt = DateTime.now().toUtc();
PrimekitLogger.info(
'Initialised — ${_remoteConfig.getAll().length} keys loaded.',
tag: _tag,
);
} on Exception catch (error, stack) {
PrimekitLogger.error(
'Failed to initialise Firebase Remote Config.',
tag: _tag,
error: error,
stackTrace: stack,
);
throw ConfigurationException(
message: 'FirebaseFlagProvider.initialize() failed: $error',
);
}
}