localized method

PaywallLocalizedContent<T> localized(
  1. Locale locale
)

Implementation

PaywallLocalizedContent<T> localized(Locale locale) {
  T? x = values[locale.languageCode];
  if (x == null && InAppPurchaser.i.configDelegate != null) {
    final l = locale;
    final d = InAppPurchaser.i.configDelegate!;
    Object? lt(Object? e) {
      if (e is String) return d.localize(l, e);
      if (e is Map) return e.map((k, v) => MapEntry(k, lt(v)));
      if (e is List) return e.map(lt).toList();
      return e;
    }

    final y = lt(value ?? values['en']);
    if (y is T) x = y;
  }
  return copyWith(value: x);
}