fcg_network_interceptor 0.0.1 copy "fcg_network_interceptor: ^0.0.1" to clipboard
fcg_network_interceptor: ^0.0.1 copied to clipboard

discontinued

A Dio interceptor that automatically encrypts request bodies using the encrypt_secure package.

FCG Network Interceptor (fcg_network_interceptor) #

A Dio interceptor that automatically encrypts request bodies using the encrypt_secure package.

Features #

  • Automatic Encryption: Intercepts POST, PUT, and PATCH requests and automatically encrypts the JSON body.
  • Request Wrapping: Wraps the encrypted string in a standardized JSON structure: {"request": "ENCRYPTED_STRING"}.
  • Selective Encryption: Provides a mechanism to skip encryption for specific requests (e.g., standard application/x-www-form-urlencoded submissions).
  • Error Handling: Catches encryption errors and wraps them in DioException for consistent error handling.

Installation #

Add the following to your pubspec.yaml:

dependencies:
  fcg_network_interceptor: ^0.0.1
  dio: ^5.0.0
  encrypt_secure: ^0.0.2

Usage #

1. Initialization #

Add the EncryptionInterceptor to your Dio instance.

import 'package:dio/dio.dart';
import 'package:fcg_network_interceptor/fcg_network_interceptor.dart';

void main() {
  final dio = Dio();
  
  // Add the interceptor to the chain
  dio.interceptors.add(EncryptionInterceptor());
  
  // Note: Ensure EncryptionService from `encrypt_secure` is initialized
  // before making requests.
}

2. Making Encrypted Requests #

By default, any POST, PUT, or PATCH request with a JSON body (Map<String, dynamic>) will be encrypted.

// This request body will be automatically encrypted
final response = await dio.post(
  '/api/secure-endpoint',
  data: {
    'userId': '12345',
    'action': 'update_profile'
  },
);

What happens over the network: The body sent to the server will look like:

{
  "request": "U2FsdGVkX1+..."
}

3. Skipping Encryption #

If you need to send a request without encryption (e.g., for application/x-www-form-urlencoded or public endpoints), use the skipEncryption option in extra.

final response = await dio.post(
  '/api/public-endpoint',
  data: {
    'grant_type': 'password',
    'username': 'user',
    'password': 'password'
  },
  options: Options(
    contentType: Headers.formUrlEncodedContentType,
    extra: {
      'skipEncryption': true, // Disables the interceptor for this request
    },
  ),
);

Dependencies #

  • dio: A powerful Http client for Dart.
  • encrypt_secure: The underlying encryption library.

License #

MIT License. See LICENSE for details.

Copyright (c) 2026 Fakeeh Tech.

0
likes
0
points
27
downloads

Publisher

unverified uploader

Weekly Downloads

A Dio interceptor that automatically encrypts request bodies using the encrypt_secure package.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, encrypt_secure, flutter

More

Packages that depend on fcg_network_interceptor