halkyon_app: data locations as precise as a country or a state

An operator's DATA_LOCATION and BACKUP_LOCATION may name a subdivision
(ISO 3166-2, US-CA, DE-BY) besides the EU or a country. The app adds
"(EU)" to a member country and the country to a subdivision ("Germany
(EU)", "California, United States", "Bavaria, Germany (EU)"), in
English and German, and shows the most specific flag there is: a
subdivision's own where the flag package has one, else its country's.
Subdivision names come from Unicode CLDR 48.2 (tool/subdivision_names.py),
bundled with their licence, which the app registers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-19 18:47:25 +02:00
commit 96f2d14618
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -0,0 +1,37 @@
import 'package:flag/flag.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_app/halkyon_app.dart';
import 'package:material_ui/material_ui.dart';
void main() {
test("a place shows the most specific flag there is: a subdivision's own, "
"else its country's, and the European Union's", () {
expect(flagCodeOf('EU'), 'eu');
expect(flagCodeOf('DE'), 'de');
expect(flagCodeOf('CH'), 'ch');
expect(flagCodeOf('DE-BY'), 'de');
expect(flagCodeOf('US-CA'), 'us');
expect(flagCodeOf('GB-SCT'), 'gb_sct');
expect(flagCodeOf('ES-CT'), 'es_ct');
expect(flagCodeOf('DE-ZZ'), 'de');
});
test('a place without a flag shows none', () {
expect(flagCodeOf('QQ'), isNull);
expect(flagCodeOf('QQ-AB'), isNull);
});
testWidgets("a state shows its country's flag, a place without one "
'nothing', (tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: Row(
children: [InstanceFlag('US-CA'), InstanceFlag('QQ-AB')],
),
),
);
expect(find.byType(Flag), findsOne);
});
}