diox library
A powerful Flutter library that enhances Dio with a simplified API response handler and adds a convenient 'shake-to-debug' feature to open Chucker.
This package is designed to streamline your networking layer and improve your debugging workflow. It provides two main components:
-
Dio Extensions (
dio_extended.dart): A wrapper around the Dio HTTP client that standardizes all responses into anApiResult<T>object. This abstracts away the boilerplatetry-catchlogic, status code checking, and JSON parsing, allowing you to write cleaner and more resilient code. -
Shake for Chucker (
shake_for_chucker.dart): A widget that enables developers to instantly open the Chucker network inspection screen by simply shaking their device. This is incredibly useful for debugging network issues on a physical device without needing to navigate through the app's UI.
Quick Start
To get started, follow these three simple steps:
-
Wrap your application with the
ShakeForChuckerwidget to enable the shake gesture. This should be done at the root of your app. -
Create an instance of the
DioExtendedclient in your widget or service class where you will be making API calls. -
Make API calls using the simplified methods like
get,post, etc. The call will return anApiResult. You can then check theisSuccessproperty to handle the response appropriately.
Classes
- DioExtended
- A base class that extends Dio functionality with standardized request handling, error wrapping, and optional token-refresh logic.
- ErrorMessages
- A collection of global error message constants used across the app.
- ShakeChuckerConfigs
-
Provides configuration utilities and integration helpers
for Chucker within the
dio_extendedpackage. - ShakeForChucker
Enums
- FormDataMethod
-
Defines which HTTP method is used for uploading
FormData.