addCustomLocale method

Future<void> addCustomLocale(
  1. String localeCode,
  2. String direction
)

Adds a custom locale with manual direction specification.

Implementation

Future<void> addCustomLocale(String localeCode, String direction) async {
  // 1. Optimistic update - immediate UI feedback
  queue.addLocaleOptimistic(localeCode, direction);
  notifyListeners();

  try {
    await _client.addLocale(locale: localeCode, direction: direction);
  } catch (e) {
    // 2. On error: rollback and refresh
    await queue.refresh(reloadMeta: true);
    notifyListeners();
    // Error will be shown by the caller
    rethrow;
  }
}