Browse Source

neon: use expand instead of reduce

pull/412/head
Nikolas Rimikis 2 years ago
parent
commit
1fdcba6915
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/neon/neon/lib/src/app.dart
  2. 2
      packages/neon/neon/lib/src/utils/localizations.dart

2
packages/neon/neon/lib/src/app.dart

@ -273,7 +273,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
supportedLocales: {
..._appImplementations
.map((final app) => app.supportedLocales)
.reduce((final value, final element) => [...value, ...element]),
.expand((final element) => element),
...AppLocalizations.supportedLocales,
},
themeMode: themeMode,

2
packages/neon/neon/lib/src/utils/localizations.dart

@ -5,7 +5,7 @@ part of '../../neon.dart';
/// When the system locale is not supported [fallbackLocale] will be used.
Future<AppLocalizations> appLocalizationsFromSystem([final Locale fallbackLocale = const Locale('en', 'US')]) async {
final systemLocale = await findSystemLocale();
final parts = systemLocale.split('_').map((final a) => a.split('.')).reduce((final a, final b) => [...a, ...b]);
final parts = systemLocale.split('_').map((final a) => a.split('.')).expand((final e) => e).toList();
final locale = Locale(parts[0], parts.length > 1 ? parts[1] : null);
final isSupported = AppLocalizations.delegate.isSupported(locale);

Loading…
Cancel
Save