merge branches
This commit is contained in:
@@ -11,6 +11,7 @@ import 'network_connectivity.dart';
|
||||
class NetworkManager {
|
||||
final Dio mainDio;
|
||||
final NetworkConnectivity _connectivity = NetworkConnectivity();
|
||||
bool _interceptorsAdded = false;
|
||||
|
||||
NetworkManager()
|
||||
: mainDio = Dio(
|
||||
@@ -21,9 +22,13 @@ class NetworkManager {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
),
|
||||
);
|
||||
) {
|
||||
_addInterceptors();
|
||||
}
|
||||
|
||||
void _addInterceptors() {
|
||||
if (_interceptorsAdded) return;
|
||||
|
||||
Future<void> addInterceptors() async {
|
||||
final requestInterceptor = InterceptorsWrapper(
|
||||
onRequest: (options, handler) {
|
||||
appLogger.info('🌐 Request: ${options.method} ${options.path}');
|
||||
@@ -47,6 +52,7 @@ class NetworkManager {
|
||||
);
|
||||
|
||||
mainDio.interceptors.add(requestInterceptor);
|
||||
_interceptorsAdded = true;
|
||||
}
|
||||
|
||||
/// Enhanced makeRequest method with comprehensive error handling
|
||||
@@ -71,8 +77,6 @@ class NetworkManager {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
Dio dioInstance = mainDio;
|
||||
|
||||
await addInterceptors();
|
||||
|
||||
Future<Response> makeApiCall(String token) async {
|
||||
final headers =
|
||||
token.isEmpty
|
||||
|
||||
Reference in New Issue
Block a user