dio_http_logger 1.0.3 copy "dio_http_logger: ^1.0.3" to clipboard
dio_http_logger: ^1.0.3 copied to clipboard

Dio network logger library for viewing request, response and error logs for any requests

dio_http_logger #

Pub Version

A powerful network interceptor for Dio, providing comprehensive logging of requests, responses and errors.

⚡ Screenshots #

Screenshot 1 Screenshot 1 Screenshot 1 Screenshot 1 Screenshot 1

⚡Features #

  • Detailed Logging: Log request method, URL, headers, query parameters, request body, response status code, headers, request time, response time, request data size, response data size and response body.
  • Error stack-trace: Stack trace data directly from Dio in error requests.
  • Easy Integration: Add the interceptor to your Dio instance with just a few lines of code.

⚡Installation #

Add dio_http_logger to your pubspec.yaml file:

 dio: ">=4.0.0 <6.0.0" //use the latest version, 5.6.0 was my latest, old version user DioError instead of DioException.  
 ..... 
 dio_http_logger: ^latest_version

⚡Getting Started #

  1. Add DioNetworkLogger.instance.dioNetworkInterceptor to your dio object/instances.
final client = Dio(); 
client.interceptors.add(DioNetworkLogger.instance.dioNetworkInterceptor!);  
  1. Set the context for internal navigation on application start or naigation start.
DioNetworkLogger.instance.context = context;  
  1. Use DioNetworkLogger.instance.overLayButtonWidget widget to direct navigate to the library (Use it at the root view of your application, this will make the button appear in every screen).
runApp(    
    MaterialApp(    
      home: Stack(    
        children: [    
          const MyApp(),    
          DioNetworkLogger.instance.overLayButtonWidget  
		 ],      
	 ),    
    ) 
);  
  1. Or you can use DioNetworkLogger.instance.startNetworkLoggerScreen() to direct navigate to the library
//Use it on any callback  
onPressed: () {  
 DioNetworkLogger.instance.context = context; 
 DioNetworkLogger.instance.startNetworkLoggerScreen(); 
 },  

⚡Push notification (Optional) #

This is an optional feature. If you want to get local push notification when the network request is triggered or any response comes from the server.

Screenshot 1 Screenshot 1
  1. Initialize the notification.
void main() async{  
   ....
  WidgetsFlutterBinding.ensureInitialized();;  
  await DioNetworkLogger.instance.initLocalNotifications();  
  runApp(  
      ..... 
  );  
}
  1. For ios configure your AppDelegate
//other imports
import flutter_local_notifications
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {

    FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
    GeneratedPluginRegistrant.register(with: registry)}
    GeneratedPluginRegistrant.register(with: self)
	if #available(iOS 10.0, *) {
       UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
    }
    return super.application(application,didFinishLaunchingWithOptions:launchOptions)
  }
}

NOTE: Used the flutter_local_notifications: ^17.2.2 plugin. If you find any issues, try to follow the documentation of flutter_local_notifications and dont forget to throw an issue in github.

5
likes
100
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

Dio network logger library for viewing request, response and error logs for any requests

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter, flutter_local_notifications, plugin_platform_interface

More

Packages that depend on dio_http_logger

Packages that implement dio_http_logger