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

Exception Handler

exception_handler #

This Dart package provides a robust framework for handling API calls, managing network connectivity, and processing exceptions in Flutter applications. It simplifies the process of making network requests, parsing responses, and handling various exceptions, making it an essential tool for Flutter developers.

Features #

  • API Handling: Simplify your API calls with a structured approach, ensuring clean and maintainable code.
  • Exception Management: Comprehensive exception handling, including network issues and HTTP errors, to improve the robustness of your applications.

Getting Started #

To start using this package, add it as a dependency in your pubspec.yaml file:

dependencies:
  exception_handler: ^latest_version

Then, import it in your Dart files where you want to use it:

import 'package:exception_handler/exception_handler.dart';

Usage #

Here's a basic example to demonstrate how you can use this package:

import 'package:exception_handler/exception_handler.dart';

// Example of making an API call
void fetchData() async {
    ApiHandler<SampleModel> apiHandler = ApiHandler(
        call: () => dio.get('your_api_endpoint'),
        parserModel: (data) => SampleModel.fromJson(data),
    );

    TaskResult<SampleModel> result = await DioExceptionHandler().callApi(apiHandler);

    result.when(
        success: (data) => print('Success: $data'),
        failure: (exception) => print('Failure: ${exception.toString()}'),
    );
}

Replace SampleModel with the appropriate data model for your application.

Additional Information #

For more information on how to use this package, contribute to its development, or file issues, please visit exception_handler. The package authors are committed to maintaining and improving this tool, and your feedback and contributions are greatly welcomed.