sky_network 1.0.7
sky_network: ^1.0.7 copied to clipboard
A robust, decoupled remote network client wrapped around Dio and Connectivity.
sky_network #
A robust, type-safe, and fully decoupled remote network client wrapper around Dio and connectivity detection. It provides automatic error interception, standardized logging, and clean functional error returns.
Features #
- Advanced Error Interceptors: Translates HTTP response codes and network failures (timeouts, dns resolution issues) into core domain
Failureabstractions automatically. - Connectivity Aware: Integrated offline/online detection systems preventing unnecessary network calls when the device is disconnected.
- Logging Pipeline: Ready-made, highly structured
pretty_dio_loggersupport for debugging network requests in staging environments.
Getting Started #
Add the package to your pubspec.yaml:
dependencies:
sky_network: ^1.0.0
Usage #
Instantiate and configure the type-safe client:
import 'package:sky_network/sky_network.dart';
void main() async {
// 1. Initialize Network Client
final networkClient = SkyNetworkClient(
baseUrl: 'https://api.example.com/',
interceptors: [
PrettyDioLogger(requestHeader: true, requestBody: true),
],
);
// 2. Perform safe GET requests returning functional results
final response = await networkClient.get<Map<String, dynamic>>('users/1');
response.fold(
(failure) => print('Failed with message: ${failure.message}'),
(data) => print('Successfully retrieved user: $data'),
);
}