When calling PhoneNumber.parse('+$phoneNumber').isValid(), the package initializes hundreds of PhoneMetadata-related objects in memory on each import, regardless of the country used.
After profiling, these are the counts observed:
PhoneMetadata → 245 instances
PhoneMetadataPatterns → 245 instances
IsoCode → 245 instances
PhoneMetadataLengths → 178 instances
This initialization occurs even when validating a single phone number, resulting in unnecessary memory usage and slower startup.
Expected Behavior:
The library should lazily load or cache only the metadata required for:
The detected country code, or
The specific ISO region used during parsing.
This would reduce startup overhead dramatically.
When calling PhoneNumber.parse('+$phoneNumber').isValid(), the package initializes hundreds of PhoneMetadata-related objects in memory on each import, regardless of the country used.
After profiling, these are the counts observed:
PhoneMetadata → 245 instances
PhoneMetadataPatterns → 245 instances
IsoCode → 245 instances
PhoneMetadataLengths → 178 instances
This initialization occurs even when validating a single phone number, resulting in unnecessary memory usage and slower startup.
Expected Behavior:
The library should lazily load or cache only the metadata required for:
The detected country code, or
The specific ISO region used during parsing.
This would reduce startup overhead dramatically.