A robust Dart package for efficient network request handling, session management, real-time network state tracking, and seamless error handling for modern applications.
- 🔐 Session-based client with auto token renewal and error handling
- 🌐 Observes and notifies about network states (offline, maintenance, etc.)
- 🧩 Extensible and easy to integrate with existing architectures
- 🧪 Built-in testing and override-friendly design
Add the package to your pubspec.yaml:
dependencies:
network_cool_client: ^1.0.0Then run:
dart pub getfinal client = NccClient(
id: 'ncc-client',
client: http.Client(),
);
final response = await client.get(Uri.parse('https://api.example.com/data'));final client = SessionClient(
id: 'session-client',
client: http.Client(),
);
final response = await client.get(
Uri.parse('https://api.example.com/secure-data'),
);You can customize token renewal, header logic, and handle session expiration seamlessly.
Check the full API reference on pub.dev → network_cool_client.
final class MySessionClient extends SessionClient {
MySessionClient({required this.sessionTokenStorage, required this.renewSessionRepository})
: super(
id: 'my-session-client',
client: Client(),
);
final LocalStorageOfSessionToken sessionTokenStorage;
final RenewSessionRepository renewSessionRepository;
@override
Future<String?> getBearerToken() async {
//Obtain the token from the datasource where you store on the login request
final token = await sessionTokenStorage.call();
return token;
}
@override
Future<bool> renewSession() async {
//Renew session as your application need
final renew = await renewSessionRepository.call();
return renew.isValid;
}
}You can find usage examples in the example/ folder.
Contributions are welcome!
- Open issues for bugs or feature requests
- Fork the repo and submit a PR
- Run
dart formatanddart testbefore submitting
To run tests and see code coverage:
dart testMIT © 2025 Coolosos