readMetadataJson static method
Future<void>
readMetadataJson(
- String downloadDir, {
- List<
MetadataSource> sources = const [MetadataSource.googleLibphonenumber, MetadataSource.applePhoneNumberKit],
Loads and caches parsed metadata for all supported regions.
By default this downloads metadata from Google libphonenumber and Apple PhoneNumberKit, then merges them into one parsed dataset.
Implementation
static Future<void> readMetadataJson(
String downloadDir, {
List<MetadataSource> sources = const [
MetadataSource.googleLibphonenumber,
MetadataSource.applePhoneNumberKit,
],
}) async {
String? filePath = await downloadMetadata(downloadDir, sources: sources);
if (filePath != null && await _loadMetadataFile(filePath)) {
return;
}
if (_loadBundledMetadata()) {
print("📦 Using bundled metadata snapshot packaged with phone_parser");
return;
}
throw StateError(
'Unable to load phone metadata from either downloaded cache or bundled fallback.',
);
}