A modular and reusable Network API Service built with Dio in Flutter. This implementation emphasizes clean code, error handling, and structured responses using modern Flutter practices.
- GET, POST, PUT, DELETE requests handled efficiently.
- Built with Dio for flexible and robust HTTP handling.
- Error handling with Dio interceptors for logging and debugging.
- Records for managing structured API responses.
- Extensions for cleaner, scalable code.
-
Clone the repository:
git clone https://github.com/rishad13/dio_with_extension
-
Install dependencies:
flutter pub get
-
Use the
NetworkApiService
class to handle API requests in your project:void _getApi() async { NetworkApiService apiService = NetworkApiService(); var response = await apiService.getAPIResponse( "https://jsonplaceholder.typicode.com/posts", {}, null); if (response.fail != null) { throw response.fail!.message; } else { log(response.success!.response.data.toString()); } }
We welcome contributions! Feel free to fork the repository, submit a pull request, or create an issue for any bugs or improvements.
💡 Let’s create robust and scalable APIs in Flutter!