ncc 0.0.6 copy "ncc: ^0.0.6" to clipboard
ncc: ^0.0.6 copied to clipboard

A robust Dart package for efficient network request handling, session management, real-time network state tracking, and seamless error handling for modern applications.

example/lib/main.dart

import 'dart:developer';
import 'dart:io';

import 'custom_client/custom_ncc_client.dart';
import 'custom_client/custom_session_client.dart';
import 'observer/custom_network_observer.dart';

Future<void> main(List<String> args) async {
  final client = MyNccClient();
  final sessionClient = MySessionClient()
    ..addObserver(
      CustomNetworkObserver(
        onNotLoggedIn: () async {
          log('Not logged in');
        },
        onOffline: () async {
          log('offline');
        },
        onUndermantenance: () async {
          log('onUndermantenance');
        },
      ),
    );

  final noSessionRequest = await client
      .get(Uri.parse('https://jsonplaceholder.typicode.com/posts/1'));

  log(
    'Response body from no session ${noSessionRequest.body}\n${noSessionRequest.request?.headers}',
  );

  await sessionClient
      .get(Uri.parse('https://jsonplaceholder.typicode.com/posts/1'));

  exit(1);
}
1
likes
160
points
86
downloads

Publisher

verified publisheryaminokishi.com

Weekly Downloads

A robust Dart package for efficient network request handling, session management, real-time network state tracking, and seamless error handling for modern applications.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#http #network #protocols #session

Documentation

API reference

License

MIT (license)

Dependencies

http, meta

More

Packages that depend on ncc