At Optiblack, some of the most impactful improvements don’t come from client requirements—they come from internal ownership and curiosity. This was one such initiative.
While working on multiple apps for a client, our team noticed we were relying on IPAPI for country detection. It was working fine—but came with recurring costs (~$20/month), added latency, and an external dependency we didn’t fully control.
So we asked: Can we build a better, leaner solution ourselves?
This wasn’t a client requirement—it was a proactive engineering decision.
What started as a quick experiment turned into a production-ready improvement.
While $20/month may seem small, over time it adds up:
By replacing this dependency, we effectively turned a $1,200 recurring expense into a one-time $40 investment.
We replaced the API with a layered detection approach:
1. GPS-Based Detection (Primary)
We use device location and reverse geocoding to determine the most accurate country ISO code when permissions are available.
2. Device Locale (Fallback)
If location access is denied, we fallback to the device’s regional settings:
String countryISO = PlatformDispatcher.instance.locale.countryCode?.toUpperCase() ?? 'US';
3. Default Fallback
If both fail, we default to “US”, ensuring the system always returns a valid country.
To make this system fully independent, we bundled a static JSON file (country_codes.json) inside the app. It contains country metadata like name, ISO code, dial code, and flag:
{"name": "United States", "code": "US", "dial_code": "+1", "flag": "🇺🇸"}
This allows instant mapping from ISO code to full country details—no network calls, no latency, no failures.
A small initiative led to meaningful impact:
This wasn’t about shipping a feature—it was about thinking beyond requirements. Identifying inefficiencies, taking initiative, and solving them quickly.
At Optiblack, we believe great engineering isn’t just about building new things—it’s about continuously optimizing what already exists.