fetchAndActivate method

Future<bool> fetchAndActivate({
  1. bool? throwError,
})

Performs a fetch and activate operation, as a convenience.

Returns bool in the same way that is done for activate. A FirebaseException maybe thrown with the following error code:

  • forbidden:
  • Thrown if the Google Cloud Platform Firebase Remote Config API is disabled

Implementation

Future<bool> fetchAndActivate({bool? throwError}) async {
  // Rethrow and errors
  final throwIt = throwError ?? false;
  bool configChanged;
  try {
    configChanged = _remoteConfig != null;
    if (configChanged) {
      configChanged = await _remoteConfig!.fetchAndActivate();
      // Notify listeners of a fetch.
      notifyListeners();
    }
  } catch (e) {
    if (throwIt) {
      rethrow;
    } else {
      configChanged = false;
      getError(e);
    }
  }
  // Either an error or _remoteConfig == null
  return configChanged;
}