nexio 0.2.0 copy "nexio: ^0.2.0" to clipboard
nexio: ^0.2.0 copied to clipboard

A production-grade Flutter networking runtime for Dio with environments, encryption, isolate parsing, retries, caching, offline queues, transfers, and observability.

example/example.md

Nexio examples #

Nexio is initialized once, then every request uses the selected environment, interceptor pipeline, parser, and lifecycle policy.

Initialize #

import 'package:flutter/material.dart';
import 'package:nexio/nexio.dart';

void main() {
  Nexio.initialize(
    environments: const {
      'dev': NexioEnvironment(baseUrl: 'https://dev.example.com'),
      'production': NexioEnvironment(baseUrl: 'https://api.example.com'),
    },
    initialEnvironment: 'dev',
    navigatorKey: ChuckerFlutter.navigatorKey,
    enableChucker: true,
    defaultLogInChucker: false,
    defaultThreadMode: ThreadMode.auto,
    parseThresholdKb: 64,
  );

  runApp(const MyApp());
}

Typed GET #

final response = await Nexio.get<List<Map<String, Object?>>>(
  '/users',
  cachePolicy: CachePolicy.cacheFirst,
  logInChucker: true,
  parser: (input) async {
    return (input! as List<Object?>)
        .map((item) => Map<String, Object?>.from(item! as Map))
        .toList();
  },
);

print(response.data);
print(response.metrics.networkDuration);
print(response.metrics.parseDuration);

Secure POST #

final response = await Nexio.post<Map<String, Object?>>(
  '/payments',
  data: const {'amountMinor': 2500, 'currency': 'USD'},
  headers: const {'X-Idempotency-Key': 'payment-unique-id'},
  encryptionMode: EncryptionMode.aesGcm,
  retryPolicy: const RetryPolicy(retries: 0),
  priority: RequestPriority.high,
  deduplicate: false,
  logInChucker: false,
  parser: (input) async => Map<String, Object?>.from(input! as Map),
);

Configure EncryptionConfig during initialization before selecting CBC or GCM. Production encryption material must come from app-owned secure provisioning and must match the backend envelope contract.

Runtime Environment Switch #

Nexio.switchEnvironment('production');

final response = await Nexio.get<Map<String, Object?>>(
  '/health',
  parser: (input) async => Map<String, Object?>.from(input! as Map),
);

More Examples #

Run the application:

cd example
flutter pub get
flutter run

Run its tests:

flutter test
flutter test integration_test/nexio_runtime_test.dart -d <device-id>
0
likes
160
points
210
downloads

Documentation

API reference

Publisher

verified publishersyedmubashirali.com

Weekly Downloads

A production-grade Flutter networking runtime for Dio with environments, encryption, isolate parsing, retries, caching, offline queues, transfers, and observability.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#networking #dio #http #cache #chucker

License

MIT (license)

Dependencies

chucker_flutter, connectivity_plus, crypto, cryptography, dio, encrypt, flutter, path_provider, synchronized, uuid, xml

More

Packages that depend on nexio