dev_base_url 0.2.0
dev_base_url: ^0.2.0 copied to clipboard
Resolves your dev backend base URL per platform — Android emulator, iOS simulator, web, desktop or physical device — with sync access after a one-time async prepare. Ideal for DI containers.
Changelog #
0.2.0 #
First version prepared for pub.dev publication.
Fixed #
prepare()no longer silently ignoreshost/portwhenresolveAsync()already resolved the samekey— a console warning is now emitted whenever explicit parameters differ from the cached resolution.- An explicit
HOSTis now validated on every platform (emulator, web, desktop), not only on physical devices. Invalid hosts such asmi-servidor,256.0.0.1or192.168.1.5:throw aStateErrorinstead of silently producing a broken URL. hostvalues are trimmed before use —' 192.168.1.5 'no longer produces a URL with embedded spaces.- Concurrent
resolveAsync()calls with the samekeynow share a single resolution (theFutureis cached, not the result). Concurrentprepare()calls with the samekeyfail deterministically: exactly one wins. - A failed resolution no longer poisons the cache — retrying with corrected parameters works.
- Embedded port range in
HOST("ip:port") is now consistent with the standalonePORTvalidation:1–65535(port0was previously accepted). - The "prepare called twice" error message now includes the offending
key. - Removed stale documentation references to a non-existent
LanBaseUrlAPI.
Added #
schemeparameter onprepare()andresolveAsync()(defaults tohttp) for local TLS setups (mkcert, Caddy, tunnels).isWebgetter onTargetPlatformOverride— the web resolution path is now fully testable through injected fakes.reset()(@visibleForTesting) to clear all caches between integration tests that useDevBaseUrl.instance.- Console warning when
HOSTincludes an embedded port andPORTis also explicitly configured — the embedded port wins and the warning says so, instead of silently ignoringPORT. - Semantic HOST warnings for values that are syntactically valid but almost
certainly wrong on the current platform:
localhost/127.0.0.1on the Android emulator (points at the AVD itself, not your machine).localhost/127.0.0.1on a physical device (points at the phone — valid only withadb reverse).10.0.2.2outside the Android emulator (the alias only exists inside the AVD's virtual network).
schemeis validated — anything other thanhttp/httpsthrows aStateError.- A
HOSTthat includes a scheme (http://192.168.1.5, a common copy-paste mistake) now throws a specific error explaining that the scheme is configured separately, instead of the generic "invalid HOST".
Changed #
- Breaking:
TargetPlatformOverrideimplementations must now provideisWeb. Update your test fakes with@override bool get isWeb => false;. kEnvHost,kEnvPort,kKeyHostandkKeyPortare no longer part of the public API — they are implementation details ofDevBaseUrlConfig.fromEnvironment().RealPlatformOverridegetters are now web-safe (kIsWebis checked before touchingPlatform).
0.1.1 #
- Refined LAN URL resolution caching and added production entry point guidance.
0.1.0 #
- Initial version: per-platform base URL resolution (Android emulator,
iOS simulator, web, desktop, physical device), sync access via
prepare()/baseUrl(), async resolution with per-keycaching,--dart-define-from-filesupport and styled console diagnostics.