zeba_academy_connectivity_manager 1.0.0 copy "zeba_academy_connectivity_manager: ^1.0.0" to clipboard
zeba_academy_connectivity_manager: ^1.0.0 copied to clipboard

Smart connectivity manager for Flutter apps with offline request queue, retry system, and connection listeners.

zeba_academy_connectivity_manager #

A lightweight Flutter connectivity management toolkit designed for apps that must work reliably even with unstable or intermittent internet connections.

zeba_academy_connectivity_manager helps developers detect network status changes, queue offline API requests, retry failed calls with automatic backoff, and manage WebSocket connections โ€” all in one simple package.


โœจ Features #

  • ๐Ÿ“ก Network Status Detection โ€“ Listen to realโ€‘time connectivity changes.
  • ๐Ÿ“ด Offline Request Queue โ€“ Automatically queue API calls when the device is offline.
  • ๐Ÿ” Automatic Retry System โ€“ Retry failed requests with configurable backoff.
  • ๐ŸŒ REST API Support โ€“ Works seamlessly with HTTP requests.
  • ๐Ÿ”Œ WebSocket Support โ€“ Manage WebSocket connections and messages.
  • ๐ŸŽง Connection Event Listeners โ€“ React to online/offline changes in real time.
  • โšก Lightweight & Fast โ€“ No unnecessary complexity or heavy dependencies.

๐Ÿ“ฆ Installation #

Add the package to your pubspec.yaml:

dependencies:
  zeba_academy_connectivity_manager: ^1.0.0

Then run:

flutter pub get

๐Ÿš€ Getting Started #

Import the package:

import 'package:zeba_academy_connectivity_manager/zeba_academy_connectivity_manager.dart';

๐Ÿ“ก Detect Connectivity Changes #

final connectivity = ConnectivityService();

connectivity.onStatusChange.listen((event) {
  if (event.status == ConnectivityStatus.online) {
    print("Device is online");
  } else {
    print("Device is offline");
  }
});

๐Ÿ“ด Queue Requests When Offline #

final queue = RequestQueue();

await queue.add(() async {
  print("Executing queued request");
});

Requests added to the queue will execute sequentially.


๐Ÿ” Retry Failed Requests #

final retryManager = RetryManager();

final result = await retryManager.retry(() async {
  // Your API call
  return "Success";
});

print(result);

The retry manager automatically retries failed requests using a backoff delay.


๐ŸŒ REST API Example #

import 'package:http/http.dart' as http;

final connectivity = ConnectivityService();
final queue = RequestQueue();
final retry = RetryManager();

Future fetchData() async {
  final online = await connectivity.isOnline();

  if (!online) {
    queue.add(() => fetchData());
    return;
  }

  return retry.retry(() async {
    final response = await http.get(
      Uri.parse("https://jsonplaceholder.typicode.com/posts"),
    );

    return response.body;
  });
}

๐Ÿ”Œ WebSocket Support #

final socket = WebSocketManager();

socket.connect("wss://echo.websocket.events");

socket.messages.listen((message) {
  print("Received: $message");
});

socket.send("Hello Server");

๐Ÿ“Š Use Cases #

This package is ideal for apps that require reliable connectivity handling:

  • Offlineโ€‘first applications
  • Messaging apps
  • Delivery or rideโ€‘sharing apps
  • Field service apps
  • Data sync systems
  • IoT dashboards

๐Ÿงช Testing #

Run tests using:

flutter test

Analyze the package:

flutter analyze

๐Ÿ“ Package Structure #

lib/
 โ”œโ”€โ”€ zeba_academy_connectivity_manager.dart
 โ””โ”€โ”€ src/
      โ”œโ”€โ”€ connectivity_service.dart
      โ”œโ”€โ”€ request_queue.dart
      โ”œโ”€โ”€ retry_manager.dart
      โ”œโ”€โ”€ websocket_manager.dart
      โ””โ”€โ”€ connectivity_event.dart

๐Ÿ”ฎ Planned Improvements #

Future versions may include:

  • Persistent offline queue (Hive/SQLite)
  • Background synchronization
  • Network quality detection
  • Smart caching
  • Automatic token refresh handling

๐Ÿค Contributing #

Contributions, bug reports, and feature requests are welcome!

If you would like to contribute, please open an issue or submit a pull request.


๐Ÿ“„ License #

This project is licensed under the GPL-3.0 License.


About Me #

โœจ Iโ€™m Sufyan bin Uzayr, an open-source developer passionate about building and sharing meaningful projects. You can learn more about me and my work at sufyanism.com or connect with me on Linkedin

Your all-in-one no-bloat hub! #

๐Ÿš€ Explore cutting-edge resources in coding, tech, and development at zeba.academy and code.zeba.academy. Empower yourself with practical skills through curated directives, real-world projects, and hands-on experience. Level up your tech game today! ๐Ÿ’ปโœจ

Zeba Academy is a learning platform dedicated to coding, technology, and development. โžก Visit our main site: zeba.academy
โžก Explore hands-on courses and resources at: code.zeba.academy
โžก Check out our YouTube for more tutorials: zeba.academy
โžก Follow us on Instagram: zeba.academy

Thank you for visiting!

0
likes
140
points
89
downloads
screenshot

Documentation

API reference

Publisher

verified publisherzeba.academy

Weekly Downloads

Smart connectivity manager for Flutter apps with offline request queue, retry system, and connection listeners.

Homepage

License

GPL-3.0 (license)

Dependencies

connectivity_plus, flutter, http, queue, web_socket_channel

More

Packages that depend on zeba_academy_connectivity_manager