6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 24f64dff
Changed files
comwell_key_app/lib/services/api.dart | 17 +++++++++++++++++ comwell_key_app/lib/services/http_client.dart | 26 ++++++++++++++++++++++++++ comwell_key_app/pubspec.yaml | 1 + 3 files changed, 44 insertions(+)
Diff
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
new file mode 100644
index 00000000..97ec4377
--- /dev/null
+++ b/comwell_key_app/lib/services/api.dart
@@ -0,0 +1,17 @@
+import 'package:comwell_key_app/services/http_client.dart';
+import 'package:dio/dio.dart';
+import 'dart:convert';
+
+class Api {
+ Dio? _dio;
+
+ Dio get dio {
+ if (_dio != null) {
+ return _dio!;
+ } else {
+ _dio = HttpClient().dio;
+ return _dio!;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/comwell_key_app/lib/services/http_client.dart b/comwell_key_app/lib/services/http_client.dart
new file mode 100644
index 00000000..f0bf1a30
--- /dev/null
+++ b/comwell_key_app/lib/services/http_client.dart
@@ -0,0 +1,26 @@
+import 'package:dio/dio.dart';
+
+
+class HttpClient {
+ final dio = _createDio();
+
+ HttpClient._privateConstructor();
+
+ static final _singleton = HttpClient._privateConstructor();
+
+ factory HttpClient() => _singleton;
+
+ static Dio _createDio() {
+ var dio = Dio(
+ BaseOptions(
+ baseUrl: "https://apidev.eldicare.vn/api/",
+ receiveTimeout: const Duration(milliseconds: 5000),
+ connectTimeout: const Duration(milliseconds: 5000),
+ sendTimeout: const Duration(milliseconds: 5000),
+ ),
+ );
+ // dio.interceptors.add(AuthInterceptor(dio));
+
+ return dio;
+ }
+}
\ No newline at end of file
diff --git a/comwell_key_app/pubspec.yaml b/comwell_key_app/pubspec.yaml
index e610cc75..d21d1b96 100644
--- a/comwell_key_app/pubspec.yaml
+++ b/comwell_key_app/pubspec.yaml
@@ -40,6 +40,7 @@ dependencies:
fake_async: ^1.3.1
get_it: ^7.7.0
flutter_native_splash: ^2.4.1
+ dio: ^5.5.0+1
dev_dependencies:
flutter_test: