Skip to content

The foundation for creating a custom network client that enables session management, cookie handling, and precise configuration of server calls.

License

Notifications You must be signed in to change notification settings

coolosos/networkcoolclient

Repository files navigation

network_cool_client

A robust Dart package for efficient network request handling, session management, real-time network state tracking, and seamless error handling for modern applications.

Pub Version Pub Likes Pub Points Pub Downloads Dart SDK Version License codecov


✨ Features

  • 🔐 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

🚀 Installation

Add the package to your pubspec.yaml:

dependencies:
  network_cool_client: ^1.0.0

Then run:

dart pub get

📆 Usage

Basic usage

final client = NccClient(
  id: 'ncc-client',
  client: http.Client(),
);

final response = await client.get(Uri.parse('https://api.example.com/data'));

Session-based usage

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.


📚 API Reference

Check the full API reference on pub.dev → network_cool_client.


💡 Examples

Creation of Custom Session 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.


🤝 Contributing

Contributions are welcome!

  • Open issues for bugs or feature requests
  • Fork the repo and submit a PR
  • Run dart format and dart test before submitting

🧪 Testing

To run tests and see code coverage:

dart test

📄 License

MIT © 2025 Coolosos

About

The foundation for creating a custom network client that enables session management, cookie handling, and precise configuration of server calls.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages