lucky_dart 1.3.2
lucky_dart: ^1.3.2 copied to clipboard
A framework for building elegant and maintainable API integrations in Dart/Flutter, inspired by Saloon PHP. Lucky Dart makes your API calls fast and elegant!
Changelog #
1.3.2 - 2026-02-20 #
Fixed #
- Race condition in
RateLimitThrottlePolicy.acquire(): concurrent waiters could push_timestamps.lengthabovemaxRequests. Fixed by replacing the single-pass post-await block with awhile(true)re-check loop. - Race condition in
TokenBucketThrottlePolicy.acquire(): concurrent waiters could drive_tokensbelow zero. Fixed with the samewhile(true)pattern.
1.3.0 - 2026-02-20 #
Added #
JitterStrategyenum (none,full,equal) — additive jitter strategies to desynchronise concurrent retries and prevent thundering herdJitteredRetryPolicydecorator — wraps anyRetryPolicyand adds bounded additive jitter viamaxJitter;Randomis injectable for deterministic tests; works with all built-in and custom retry policiesLinearBackoffRetryPolicy— retries with a constant delay between attempts; useful when recovery time is predictableImmediateRetryPolicy— retries without any delay; for transient network glitches expected to resolve within millisecondsTokenBucketThrottlePolicy— token bucket algorithm with configurablecapacity,refillRate, and optionalmaxWaitTime; allows controlled bursts unlike the strict sliding-windowRateLimitThrottlePolicyConcurrencyThrottlePolicy— limits simultaneous in-flight requests via a semaphore; waiters served in FIFO order; supports optionalmaxWaitTime
Changed #
ThrottlePolicyinterface gains arelease()method with a default no-op implementation — existing customThrottlePolicysubclasses are unaffectedConnector.send()now callsthrottlePolicy?.release()in atry/finallyblock inside the retry loop, so every attempt properly releases its slot
1.2.0 - 2026-02-20 #
Added #
RetryPolicyabstract interface — implement to control retry behaviour on failed requestsThrottlePolicyabstract interface — implement to rate-limit outgoing requestsExponentialBackoffRetryPolicy— concrete retry implementation with configurablemaxAttempts,initialDelay,multiplier,maxDelay, andretryOnStatusCodesRateLimitThrottlePolicy— concrete sliding-window throttle with configurablemaxRequests,windowDuration, and optionalmaxWaitTimeLuckyThrottleException extends LuckyException— thrown whenmaxWaitTimeis exceeded; never triggers a retry even when aRetryPolicyis configuredConnector.retryPolicyandConnector.throttlePolicynullable getters — nil by default, re-evaluated on everysend()call
Changed #
Connector.send()rewritten as awhileloop to support retry and throttle orchestration without changes to the Dio layer
1.1.0 - 2026-02-20 #
Added #
LuckyLogCallbackandLuckyDebugCallbacknamed typedefs exported from the package — use them to annotate your own callback variables instead of repeating the verbose inline function typesLuckyParseException extends LuckyException— thrown by response parsing helpers when the body cannot be cast to the expected type; exposescause(the originalTypeError) and a descriptive message ("Expected Map<String, dynamic>, got String")
Changed #
LuckyResponse.json(),jsonList(),text(),bytes()now throwLuckyParseExceptioninstead of a rawTypeErroron type mismatch
1.0.1 - 2026-02-19 #
Fixed #
- Add
example/lucky_dart_example.dartfor pub.dev scoring - Document implicit constructors on
AuthenticatorandConfigMerger - Fix repository URL in
pubspec.yaml(owlnext-fr/lucky)
All notable changes to Lucky Dart will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.0 - 2026-02-19 #
Added #
- Core layer — abstract
Connector,Request,LuckyResponse,ConfigMerger - Body mixins —
HasJsonBody,HasFormBody,HasMultipartBody,HasXmlBody,HasTextBody,HasStreamBody - Authentication —
Authenticatorinterface,TokenAuthenticator,BasicAuthenticator,QueryAuthenticator,HeaderAuthenticator - Pluggable per-request auth —
Connector.authenticator(runtime-mutable getter),Connector.useAuth,Request.useAuth(bool?override) - Interceptors —
LoggingInterceptor,DebugInterceptor(callback-based, no logging dependency) - Typed exceptions —
LuckyException,ConnectionException,LuckyTimeoutException,NotFoundException(404),UnauthorizedException(401),ValidationException(422) - Dio integration —
validateStatus: (_) => trueso Lucky controls all HTTP error handling, not Dio - Full English dartdoc on all public APIs
- 112 tests (89 unit + 13 integration via
dart:iomock server)