jh_services library

A lightweight service package for Flutter to handle network requests, local storage, connectivity, and media selection seamlessly.

Classes

BaseService
Base interface for all services within jh_services.
ConnectivityConfig
Configuration options for ConnectivityService.
ConnectivityService
Service for monitoring device internet connectivity.
ErrorModel
Model representing an API or server error.
FilePickerService
Service for picking files from the device's storage.
ImagePickerService
Service for picking images and videos from the device's camera or gallery.
NetworkConfig
Configuration settings for NetworkService.
NetworkService
Service for executing HTTP/REST network requests using Dio.
SharedPrefsConfig
Configuration options for SharedPrefsService.
SharedPrefsService
Service for managing local persistent key-value storage using SharedPreferences.

Properties

serviceLocator → GetIt
Global service locator instance managed by GetIt.
final

Functions

convertImageToMultipartFile(XFile image) → Future<MultipartFile>
Converts an image file to a MultipartFile for API upload.
handleDioExceptions(DioException e) → void
Handles DioException and maps it to a standardized ServerException.
initializeAllServices() → Future<void>
Initializes all services registered in serviceLocator.
setupServiceLocator({required NetworkConfig networkConfig, SharedPrefsConfig? sharedPrefsConfig, ConnectivityConfig? connectivityConfig}) → Future<void>
Registers and initializes all core services with the given configuration.

Exceptions / Errors

ServerException
Exception thrown when a network or server request fails.