busbus 0.1.3 copy "busbus: ^0.1.3" to clipboard
busbus: ^0.1.3 copied to clipboard

discontinuedreplaced by: busenet

A new Flutter network package.

This package is a custom network layer for Flutter that leverages the popular Dio HTTP client library to manage API requests. It provides a generic response model and supports optional request-based caching. The caching feature reduces unnecessary network traffic and improves application performance when the same API request is made multiple times.

With this package, you can easily manage your application's network layer and develop faster, more efficient applications.

Features #

  • Generic response model
  • Request-based caching
  • Customizable request headers, query parameters, and request body, including support for multipart file uploads.

Getting Started #

Installation #

Add the following dependency to your pubspec.yaml file:

dependencies:
  busbus: ^0.1.0

Usage #

Import the package

import 'package:busbus/busbus.dart';

Create a new Network Manager instance

...
INetworkManager manager = NetworkManager<SampleResponseModel>()
        ..initialize(
          NetworkConfiguration('<base-url>'),
          responseModel: SampleResponseModel(),
          cacheStoreKey: 'boilerplate_cache',
          entityKey: 'body', // optional - defaults to 'body' || 'data' || 'result'
        );
...

Make a request

...
final response = await coreDio.send<SamplePostModel, SamplePostModel>(
      '${NetworkPaths.getSamplePost}/1',
      parserModel: const SamplePostModel(),
      type: HttpTypes.get,
      cachePolicy: CachePolicy.forceCache, // optional - defaults to CachePolicy.noCache
      maxStale: const Duration(seconds: 10), // optional - defaults to 10 seconds if cachePolicy is CachePolicy.forceCache
    ) as SampleResponseModel;

    switch (response.statusCode) {
      case 1:
        return response.data as SamplePostModel;
      default:
        return null;
    }
...

License #

This project is licensed under the MIT License - see the LICENSE file for details

0
likes
115
points
22
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter network package.

Documentation

API reference

License

MIT (license)

Dependencies

dio, dio_cache_interceptor, dio_cache_interceptor_hive_store, flutter, path_provider

More

Packages that depend on busbus