Browse Source

Merge pull request #412 from Leptopoda/performance/list_expansion

neon: use expand instead of reduce
pull/402/head
Nikolas Rimikis 1 year ago committed by GitHub
parent
commit
76e5ac5d79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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: { supportedLocales: {
..._appImplementations ..._appImplementations
.map((final app) => app.supportedLocales) .map((final app) => app.supportedLocales)
.reduce((final value, final element) => [...value, ...element]), .expand((final element) => element),
...AppLocalizations.supportedLocales, ...AppLocalizations.supportedLocales,
}, },
themeMode: themeMode, 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. /// When the system locale is not supported [fallbackLocale] will be used.
Future<AppLocalizations> appLocalizationsFromSystem([final Locale fallbackLocale = const Locale('en', 'US')]) async { Future<AppLocalizations> appLocalizationsFromSystem([final Locale fallbackLocale = const Locale('en', 'US')]) async {
final systemLocale = await findSystemLocale(); 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 locale = Locale(parts[0], parts.length > 1 ? parts[1] : null);
final isSupported = AppLocalizations.delegate.isSupported(locale); final isSupported = AppLocalizations.delegate.isSupported(locale);

Loading…
Cancel
Save