searchPostOffices function
Searches Pakistan Post's directory by office name, town or post code.
Matching is case-insensitive: an office matches when its name or town contains the query, or its code starts with it. Results are sorted by post code.
Implementation
List<PostOffice> searchPostOffices(String query) {
final key = normalizeKey(query);
if (key.isEmpty) return [];
final codePrefix = jsTrim(query);
return [
for (final office in _postOffices)
if (normalizeKey(office.office).contains(key) ||
normalizeKey(office.town).contains(key) ||
office.code.startsWith(codePrefix))
office,
];
}