CCCI Utility

This documentation provides an overview of the CCCI Utils, including custom widgets, utility classes, and network handling.

Table of Contents

  1. Utility Classes

Utility Classes

AppLogger

The AppLogger class is a utility class for logging messages in the application at different levels of severity. It provides static methods for logging debug, info, warning, error, and verbose messages. Additionally, it includes methods for logging API requests, responses, and errors.

Usage:

AppLogger.debug('Debug message');
AppLogger.error('Error message');
AppLogger.logApiRequest(url: 'https://api.example.com', method: 'GET');

RouteHandler

The RouteHandler class is a utility class for handling navigation operations within the application. It provides methods for pushing, popping, and replacing routes in the navigator stack. These methods facilitate seamless navigation between different screens and components within the application.

RouteHandler.push(context, HomePage());
RouteHandler.pop(context);

DioExceptions

The DioExceptions class is a custom exception class that handles errors from Dio requests. It provides custom error messages based on different types of Dio exceptions encountered, including connection timeouts, receive timeouts, bad responses, and unknown errors.

Usage:

try {
  // Dio request
} catch (e) {
  if (e is DioException) {
    final dioException = DioExceptions.fromDioError(e);
    print(dioException.message);
  }
}

DioClient

The DioClient class encapsulates functionality for making HTTP requests using the Dio package. It includes methods for making GET, POST, PUT, and DELETE requests with configurable options and interceptors. This class provides a convenient and efficient way to interact with APIs and handle network requests within the application.

Dart Dependencies

To use the DioClient, you need to have the following Dart packages in your pubspec.yaml:

dependencies:
    dio
    flutter_dotenv

Configuration Files

Make sure you have the necessary configuration files:

  1. . env

    Usage:
    BASE_URL=<your_base_url>
    
  2. config.json

    Usage:
    {
      "development": {
        "current": true,
        "baseUrl": "https://dev.example.com"
      },
      "production": {
        "current": false,
        "baseUrl": "https://api.example.com"
      }
    }