Refactor code for consistency and readability

- Removed unused imports and commented-out code
- Updated class inheritance for AuthState subclasses
- Reorganized code structure for better readability
- Cleaned up debug print statements and replaced with dart:developer logs
This commit is contained in:
Mohammad Salameh
2024-04-15 12:03:25 +03:00
parent cfc395e210
commit 80d424f114
13 changed files with 162 additions and 77 deletions

View File

@ -1,5 +1,5 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'dart:developer' as developer;
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
import 'package:syncrow_app/services/api/http_interceptor.dart';
import 'package:syncrow_app/services/locator.dart';
@ -39,9 +39,6 @@ class HTTPService {
);
return expectedResponseModel(response.data);
} catch (error) {
debugPrint("******* Error");
debugPrint(error.toString());
debugPrint("******* Error End");
rethrow;
}
}
@ -60,8 +57,8 @@ class HTTPService {
queryParameters: queryParameters,
options: options,
);
// debugPrint("status code is ${response.statusCode}");
// debugPrint("response data is ${response.data}");
// developer.log("status code is ${response.statusCode}");
// developer.log("response data is ${response.data}");
return expectedResponseModel(response.data);
} catch (error) {
rethrow;
@ -79,11 +76,11 @@ class HTTPService {
data: body,
queryParameters: queryParameters,
);
debugPrint("status code is ${response.statusCode}");
developer.log("status code is ${response.statusCode}");
return expectedResponseModel(response.data);
} catch (error) {
debugPrint("******* Error");
debugPrint(error.toString());
developer.log("******* Error");
developer.log(error.toString());
rethrow;
}
}
@ -94,26 +91,25 @@ class HTTPService {
Map<String, dynamic>? queryParameters,
required T Function(dynamic) expectedResponseModel}) async {
try {
debugPrint("download begins");
developer.log("download begins");
final response = await client.download(
path,
savePath,
onReceiveProgress: (current, total) {
debugPrint("current = $current, while total = $total");
developer.log("current = $current, while total = $total");
},
);
debugPrint("download ends");
developer.log("download ends");
return expectedResponseModel(response.data);
// return expectedResponseModel(response.data);
} catch (error) {
debugPrint("******* Error");
debugPrint("download error");
debugPrint(error.toString());
developer.log("******* Error");
developer.log("download error");
developer.log(error.toString());
rethrow;
}
}
//delete
Future<T> delete<T>({
required String path,
Map<String, dynamic>? queryParameters,
@ -127,8 +123,8 @@ class HTTPService {
);
return expectedResponseModel(response.data);
} catch (error) {
debugPrint("******* Error");
debugPrint(error.toString());
developer.log("******* Error");
developer.log(error.toString());
rethrow;
}
}