fetchAndActivate method

Future<void> fetchAndActivate()

Fetches the latest values from Firebase and activates them.

Called by RemoteConfigSyncTask during the startup sequence, after connectivity has been confirmed. This is the only fetch performed at cold launch — no fetch happens during DI initialisation.

In staging (minimumFetchInterval = zero) this always retrieves the latest values; in production it refreshes once the 12-hour cache window has expired.

A failed fetch is logged and swallowed — the app continues with whatever values are currently activated (defaults or the last successful fetch).

Implementation

Future<void> fetchAndActivate() async {
  _logger.info('[RemoteConfig] fetchAndActivate: fetching latest values');
  try {
    final bool updated = await _remoteConfig.fetchAndActivate();
    if (updated) {
      _logger.info('[RemoteConfig] fetchAndActivate: new config activated');
    } else {
      _logger.info('[RemoteConfig] fetchAndActivate: config up to date');
    }
  } on FirebaseException catch (e, st) {
    _handleFirebaseException(e, st, 'fetchAndActivate');
  }
}