Skip to content

Commit 80f443c

Browse files
chore: update CHANGELOG for version 0.0.12, optimize dependencies by removing http package, unify HTTP client with dio, and update version references in pubspec.yaml and README.md
1 parent 2f26c56 commit 80f443c

6 files changed

Lines changed: 61 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.12] - 2026-01-09
9+
10+
### Changed
11+
12+
#### Dependency Optimization
13+
- **Removed `http` package** - Eliminated redundant HTTP client dependency
14+
- **Unified HTTP client** - `ApiVersionProvider` now uses `dio` instead of `http`
15+
- Better error handling with `DioException`
16+
- Consistent with other HTTP operations in the codebase
17+
- Proper resource cleanup with `dispose()`
18+
19+
### Removed
20+
- `http: ^1.2.0` dependency from pubspec.yaml
21+
22+
[0.0.12]: https://github.com/gurkanfikretgunak/masterfabric_core/releases/tag/v0.0.12
23+
824
## [0.0.11] - 2026-01-09
925

1026
### Changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Add this to your package's `pubspec.yaml` file:
9393

9494
```yaml
9595
dependencies:
96-
masterfabric_core: ^0.0.11
96+
masterfabric_core: ^0.0.12
9797
```
9898
9999
Then run:
@@ -407,7 +407,7 @@ For detailed documentation, see:
407407

408408
- **Pub.dev**: [https://pub.dev/packages/masterfabric_core](https://pub.dev/packages/masterfabric_core)
409409
- **GitHub**: [https://github.com/gurkanfikretgunak/masterfabric_core](https://github.com/gurkanfikretgunak/masterfabric_core)
410-
- **Version**: 0.0.11
410+
- **Version**: 0.0.12
411411
- **License**: AGPL-3.0
412412

413413
## Contributing
@@ -438,7 +438,7 @@ Or add it manually to your `pubspec.yaml`:
438438

439439
```yaml
440440
dependencies:
441-
masterfabric_core: ^0.0.11
441+
masterfabric_core: ^0.0.12
442442
```
443443
444444
---

example/lib/views/home/home_view.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class HomeView extends MasterViewCubit<HomeCubit, HomeState> {
130130
borderRadius: BorderRadius.circular(4),
131131
),
132132
child: Text(
133-
'v0.0.11',
133+
'v0.0.12',
134134
style: AppTheme.mono.copyWith(
135135
fontSize: 11,
136136
color: AppTheme.success,
@@ -436,7 +436,7 @@ class HomeView extends MasterViewCubit<HomeCubit, HomeState> {
436436
context,
437437
'1',
438438
'Add dependency',
439-
'masterfabric_core: ^0.0.11',
439+
'masterfabric_core: ^0.0.12',
440440
),
441441
const SizedBox(height: 12),
442442
_buildCodeStep(

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ packages:
667667
path: ".."
668668
relative: true
669669
source: path
670-
version: "0.0.10"
670+
version: "0.0.11"
671671
matcher:
672672
dependency: transitive
673673
description:

lib/src/helper/force_update/providers/api_version_provider.dart

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import 'dart:convert';
1+
import 'package:dio/dio.dart';
22
import 'package:flutter/foundation.dart';
3-
import 'package:http/http.dart' as http;
43

54
import 'version_provider.dart';
65

@@ -15,37 +14,48 @@ class ApiVersionProvider implements VersionProvider {
1514
/// Timeout duration
1615
final Duration timeout;
1716

18-
/// HTTP client (for testing)
19-
final http.Client? client;
17+
/// Dio client (for testing or custom configuration)
18+
final Dio? dio;
19+
20+
/// Internal dio instance
21+
Dio? _internalDio;
2022

2123
ApiVersionProvider({
2224
required this.endpoint,
2325
this.headers,
2426
this.timeout = const Duration(seconds: 10),
25-
this.client,
27+
this.dio,
2628
});
2729

30+
Dio get _dio {
31+
if (dio != null) return dio!;
32+
33+
_internalDio ??= Dio(BaseOptions(
34+
connectTimeout: timeout,
35+
receiveTimeout: timeout,
36+
headers: {
37+
'Content-Type': 'application/json',
38+
...?headers,
39+
},
40+
));
41+
42+
return _internalDio!;
43+
}
44+
2845
@override
2946
Future<VersionData> fetchVersionInfo() async {
3047
try {
31-
final httpClient = client ?? http.Client();
32-
33-
final response = await httpClient
34-
.get(
35-
Uri.parse(endpoint),
36-
headers: {
37-
'Content-Type': 'application/json',
38-
...?headers,
39-
},
40-
)
41-
.timeout(timeout);
48+
final response = await _dio.get<Map<String, dynamic>>(endpoint);
4249

4350
if (response.statusCode != 200) {
4451
throw Exception(
4552
'API request failed with status: ${response.statusCode}');
4653
}
4754

48-
final data = json.decode(response.body) as Map<String, dynamic>;
55+
final data = response.data;
56+
if (data == null) {
57+
throw Exception('API response is empty');
58+
}
4959

5060
// Support various API response formats
5161
// Format 1: Direct response
@@ -69,6 +79,9 @@ class ApiVersionProvider implements VersionProvider {
6979

7080
// Fallback: try to parse the whole response
7181
return VersionData.fromJson(data);
82+
} on DioException catch (e) {
83+
debugPrint('ApiVersionProvider DioException: ${e.message}');
84+
rethrow;
7285
} catch (e) {
7386
debugPrint('ApiVersionProvider error: $e');
7487
rethrow;
@@ -78,11 +91,12 @@ class ApiVersionProvider implements VersionProvider {
7891
@override
7992
Future<bool> isAvailable() async {
8093
try {
81-
final httpClient = client ?? http.Client();
82-
83-
final response = await httpClient
84-
.head(Uri.parse(endpoint))
85-
.timeout(const Duration(seconds: 5));
94+
final response = await _dio.head<void>(
95+
endpoint,
96+
options: Options(
97+
receiveTimeout: const Duration(seconds: 5),
98+
),
99+
);
86100

87101
return response.statusCode == 200 || response.statusCode == 405;
88102
} catch (e) {
@@ -92,6 +106,7 @@ class ApiVersionProvider implements VersionProvider {
92106

93107
@override
94108
void dispose() {
95-
// Client is typically external, don't dispose
109+
_internalDio?.close();
110+
_internalDio = null;
96111
}
97112
}

pubspec.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: masterfabric_core
22
description: "Core utilities, base classes, and shared logic for the MasterFabric Flutter project."
3-
version: 0.0.11
3+
version: 0.0.12
44
homepage: https://github.com/gurkanfikretgunak/masterfabric_core
55
repository: https://github.com/gurkanfikretgunak/masterfabric_core
66

@@ -31,7 +31,6 @@ dependencies:
3131
# Utilities
3232
logger: ^2.5.0
3333
dio: ^5.7.0
34-
http: ^1.2.0
3534
shared_preferences: ^2.5.3
3635
hive_ce: ^2.16.0
3736
sqflite: ^2.4.2

0 commit comments

Comments
 (0)