finds.dev← search

// the find

felangel/fresh

★ 428 · Dart · updated Feb 2026

🍋 A token refresh library for Dart.

fresh is a set of Dart packages that handle OAuth2 token refresh for HTTP clients: a core package plus thin adapters for dio, package:http and gql_link. It is aimed at Flutter and Dart apps that call authenticated APIs and want refresh-on-auth-failure with request retry, without writing the concurrency logic themselves.

Single-flight refresh is the part most hand-rolled token code gets wrong, and each adapter has a concurrent_refresh_test.dart, so the behavior is exercised rather than just described. The core is transport-agnostic and the adapters are small, so one TokenStorage and one refresh callback can back dio, http and GraphQL clients without three separate implementations. TokenStorage and the refresh function are plain interfaces and closures, so persistence and the refresh endpoint stay the caller's decision and nothing forces a base-class hierarchy.

fresh_graphql has no HTTP status to key off, so it depends on the shouldRefresh predicate matching the server's error text. The README example checks for the string 'UNAUTHENTICATED', which stops triggering refresh without any error when the backend renames its error code. Proactive refresh only works if expiresAt is set, and the README and examples build OAuth2Token without it, so unless you map the expiry from your refresh response yourself you get reactive refresh only and the headline feature does not apply. Every example uses InMemoryTokenStorage and the library ships no persistent or secure storage, so anyone shipping to real users has to write the TokenStorage adapter on top of something like flutter_secure_storage. The root README does not say which core version each adapter targets, and the pubspec_overrides files suggest the packages are developed against local paths, so keeping fresh and its adapters in step is left to you.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →