Raise the declared minimums in pubspec.yaml to what our deps already require: Flutter >=3.35.0 / Dart >=3.9.0 (was 3.19.0 / 3.5.0). alchemist 0.12 needs Flutter 3.32; Dart 3.9 first ships in Flutter 3.35, so 3.35 is the binding floor. Pin the exact build toolchain in .fvmrc (Flutter 3.44.1). Moving to the Dart 3.9 language level switches `dart format` to the new "tall" style and enables two new lints. This commit is the resulting mechanical churn, isolated from any behaviour change: - whole-tree `dart format` reformat (tall style) - `dart fix` for unnecessary_underscores + use_null_aware_elements No runtime behaviour change; `make test` green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
48 lines
1.5 KiB
Dart
48 lines
1.5 KiB
Dart
import 'dart:ui';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
/// Resolves the ordered list of locales to try when looking up a key.
|
|
///
|
|
/// Order, starting from the current locale:
|
|
/// 1. exact (language + country) — e.g. nl_NL
|
|
/// 2. language-only — e.g. nl
|
|
/// 3. default language + country — e.g. en_US
|
|
/// 4. default language-only — e.g. en
|
|
///
|
|
/// Duplicates are removed while preserving order. `null` country code is
|
|
/// canonicalized by omitting it (not empty string) so equality works.
|
|
@immutable
|
|
class FallbackChain {
|
|
const FallbackChain({required this.current, required this.defaultLocale});
|
|
|
|
final Locale current;
|
|
final Locale defaultLocale;
|
|
|
|
List<Locale> resolve() {
|
|
final out = <Locale>[];
|
|
for (final l in [current, Locale(current.languageCode), defaultLocale, Locale(defaultLocale.languageCode)]) {
|
|
final canon = _canon(l);
|
|
if (!out.any((e) => _canon(e) == canon)) {
|
|
out.add(l);
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
|
|
static String _canon(Locale l) {
|
|
final country = l.countryCode;
|
|
if (country == null || country.isEmpty) return l.languageCode;
|
|
return '${l.languageCode}_$country';
|
|
}
|
|
|
|
/// Canonical filename suffix for a locale, matching fframe: `en_us`
|
|
/// (lowercase, country only when present).
|
|
static String filenameSuffix(Locale l) {
|
|
final lang = l.languageCode.toLowerCase();
|
|
final country = l.countryCode?.toLowerCase();
|
|
if (country == null || country.isEmpty) return lang;
|
|
return '${lang}_$country';
|
|
}
|
|
}
|