setFallbackLocale method

Future<void> setFallbackLocale(
  1. String locale,
  2. BuildContext? context
)

Updates the fallback locale in config.

Implementation

Future<void> setFallbackLocale(String locale, BuildContext? context) async {
  // Optimistic update
  if (queue.meta != null) {
    queue.addLocaleOptimistic('temp', 'ltr');
    notifyListeners();
  }

  try {
    await _client.updateFallbackLocale(fallbackLocale: locale);
    await queue.refresh(reloadMeta: true);
    notifyListeners();
  } catch (e) {
    await queue.refresh(reloadMeta: true);
    notifyListeners();
    rethrow;
  }
}