import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import '../ui/common/app_constants.dart'; class DioService { final Dio _dio = Dio(); DioService() { _dio.options.baseUrl = baseUrl; _dio.options.connectTimeout = const Duration(seconds: 30); _dio.options.receiveTimeout = const Duration(seconds: 30); _dio.interceptors.add( InterceptorsWrapper( onRequest: (options, handler) { debugPrint('➡️➡️➡️ REQUEST ➡️➡️➡️'); debugPrint('➡️ Data: ${options.data}'); debugPrint('➡️ Headers: ${options.headers}'); debugPrint('➡️ ${options.method} ${options.uri}'); handler.next(options); }, onResponse: (response, handler) { debugPrint('✅✅✅ RESPONSE ✅✅✅'); debugPrint('✅ Data : ${response.data}'); debugPrint('✅ Status Code : ${response.statusCode}'); handler.next(response); }, onError: (error, handler) { debugPrint('❌❌❌ ERROR ❌❌❌'); debugPrint('❌ ${error.message}'); debugPrint('❌ URI: ${error.requestOptions.uri}'); debugPrint('❌ Headers sent: ${error.requestOptions.headers}'); handler.next(error); }, ), ); } Dio get dio => _dio; }