Skip to content

Commit 8fefc85

Browse files
authored
feat: Upgrade various dependencies and fix warnings (#824)
BREAKING CHANGE: Upgrades to dio 5.x
1 parent dc00f63 commit 8fefc85

16 files changed

+125
-116
lines changed

packages/dart/CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [4.0.0](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-3.1.14...dart-4.0.0) (2023-03-07)
2+
3+
### BREAKING CHANGES
4+
5+
* Upgrades to dio 5.x ([#824](https://github.com/parse-community/Parse-SDK-Flutter/pull/824))
6+
7+
### Feature
8+
9+
* Upgrade various dependencies and fix warnings ([#824](https://github.com/parse-community/Parse-SDK-Flutter/pull/824))
10+
111
## [3.1.15](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-3.1.14...dart-3.1.15) (2023-02-28)
212

313
### Bug Fixes
@@ -173,7 +183,7 @@ Bug fixes
173183
## 1.0.22
174184

175185
Added dirty children
176-
Added option of sembast or share_preferences
186+
Added option of sembast or share_preferences
177187

178188
## 1.0.21
179189

@@ -195,7 +205,7 @@ Bug fix
195205

196206
## 1.0.17
197207

198-
LiveQuery fix
208+
LiveQuery fix
199209
Bug fixes
200210

201211
## 1.0.16

packages/dart/lib/parse_server_sdk.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library flutter_parse_sdk;
22

33
import 'dart:async';
44
import 'dart:convert';
5-
import 'dart:io';
5+
import 'package:universal_io/io.dart';
66
import 'dart:math';
77
import 'dart:typed_data';
88
import 'package:dio/dio.dart';
@@ -142,9 +142,9 @@ class Parse {
142142

143143
Future<ParseResponse> healthCheck(
144144
{bool? debug, ParseClient? client, bool? sendSessionIdByDefault}) async {
145-
final bool _debug = isDebugEnabled(objectLevelDebug: debug);
145+
final bool debugLocal = isDebugEnabled(objectLevelDebug: debug);
146146

147-
final ParseClient _client = client ??
147+
final ParseClient clientLocal = client ??
148148
ParseCoreData().clientCreator(
149149
sendSessionId:
150150
sendSessionIdByDefault ?? ParseCoreData().autoSendSessionId,
@@ -154,11 +154,11 @@ class Parse {
154154
const ParseApiRQ type = ParseApiRQ.healthCheck;
155155

156156
try {
157-
final ParseNetworkResponse response =
158-
await _client.get('${ParseCoreData().serverUrl}$keyEndPointHealth');
159-
return handleResponse<Parse>(null, response, type, _debug, className);
157+
final ParseNetworkResponse response = await clientLocal
158+
.get('${ParseCoreData().serverUrl}$keyEndPointHealth');
159+
return handleResponse<Parse>(null, response, type, debugLocal, className);
160160
} on Exception catch (e) {
161-
return handleException(e, type, _debug, className);
161+
return handleException(e, type, debugLocal, className);
162162
}
163163
}
164164
}

packages/dart/lib/src/base/parse_constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
part of flutter_parse_sdk;
22

33
// Library
4-
const String keySdkVersion = '3.1.15';
4+
const String keySdkVersion = '4.0.0';
55
const String keyLibraryName = 'Flutter Parse SDK';
66

77
// End Points

packages/dart/lib/src/network/dio_adapter_io.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import 'dart:io';
1+
import 'package:universal_io/io.dart';
22

3-
import 'package:dio/adapter.dart';
3+
import 'package:dio/io.dart';
44
import 'package:dio/dio.dart';
55

66
HttpClientAdapter createHttpClientAdapter(SecurityContext? securityContext) {
7-
final DefaultHttpClientAdapter defaultHttpClientAdapter =
8-
DefaultHttpClientAdapter();
7+
final IOHttpClientAdapter defaultHttpClientAdapter = IOHttpClientAdapter();
98

109
if (securityContext != null) {
1110
defaultHttpClientAdapter.onHttpClientCreate =

packages/dart/lib/src/network/dio_adapter_js.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import 'dart:io';
2-
3-
import 'package:dio/adapter_browser.dart';
1+
import 'package:dio/browser.dart';
42
import 'package:dio/dio.dart';
53

6-
HttpClientAdapter createHttpClientAdapter(SecurityContext? securityContext) {
4+
HttpClientAdapter createHttpClientAdapter(dynamic securityContext) {
75
final BrowserHttpClientAdapter browserHttpClientAdapter =
86
BrowserHttpClientAdapter();
97
return browserHttpClientAdapter;

packages/dart/lib/src/network/parse_dio_client.dart

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import 'dart:io';
2-
31
import 'package:dio/dio.dart' as dio;
42
import 'package:parse_server_sdk/parse_server_sdk.dart';
53

64
import 'dio_adapter_io.dart' if (dart.library.js) 'dio_adapter_js.dart';
75

86
class ParseDioClient extends ParseClient {
9-
ParseDioClient(
10-
{bool sendSessionId = false, SecurityContext? securityContext}) {
7+
// securityContext is SecurityContext
8+
ParseDioClient({bool sendSessionId = false, dynamic securityContext}) {
119
_client = _ParseDioClient(
1210
sendSessionId: sendSessionId,
1311
securityContext: securityContext,
@@ -66,7 +64,8 @@ class ParseDioClient extends ParseClient {
6664
statusCode: error.response?.statusCode ?? ParseError.otherCause,
6765
);
6866
} else {
69-
return _getOtherCaseErrorForParseNetworkResponse(error.error);
67+
return _getOtherCaseErrorForParseNetworkResponse(
68+
error.error.toString());
7069
}
7170
}
7271
}
@@ -141,7 +140,8 @@ class ParseDioClient extends ParseClient {
141140
statusCode: error.response?.statusCode ?? ParseError.otherCause,
142141
);
143142
} else {
144-
return _getOtherCaseErrorForParseNetworkResponse(error.error);
143+
return _getOtherCaseErrorForParseNetworkResponse(
144+
error.error.toString());
145145
}
146146
}
147147
}
@@ -178,8 +178,7 @@ class ParseDioClient extends ParseClient {
178178

179179
/// Creates a custom version of HTTP Client that has Parse Data Preset
180180
class _ParseDioClient with dio.DioMixin implements dio.Dio {
181-
_ParseDioClient(
182-
{bool sendSessionId = false, SecurityContext? securityContext})
181+
_ParseDioClient({bool sendSessionId = false, dynamic securityContext})
183182
: _sendSessionId = sendSessionId {
184183
options = dio.BaseOptions();
185184
httpClientAdapter = createHttpClientAdapter(securityContext);
@@ -243,7 +242,7 @@ class _ParseDioClient with dio.DioMixin implements dio.Dio {
243242

244243
void _logCUrl(dio.Options options, dynamic data, String url) {
245244
String curlCmd = 'curl';
246-
curlCmd += ' -X ' + options.method!;
245+
curlCmd += ' -X ${options.method!}';
247246
bool compressed = false;
248247
options.headers!.forEach((String name, dynamic value) {
249248
if (name.toLowerCase() == 'accept-encoding' &&
@@ -272,8 +271,8 @@ class _ParseDioClient with dio.DioMixin implements dio.Dio {
272271
class _Options extends dio.Options {
273272
_Options({
274273
String? method,
275-
int? sendTimeout,
276-
int? receiveTimeout,
274+
Duration? sendTimeout,
275+
Duration? receiveTimeout,
277276
Map<String, dynamic>? extra,
278277
Map<String, dynamic>? headers,
279278
dio.ResponseType? responseType,

packages/dart/lib/src/network/parse_http_client.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dart:convert';
2-
import 'dart:io';
2+
import 'package:universal_io/io.dart';
33

44
import 'package:http/http.dart' as http;
55
import 'package:http/io_client.dart';
@@ -161,7 +161,7 @@ class _ParseHTTPClient extends http.BaseClient {
161161

162162
void _logCUrl(http.BaseRequest request) {
163163
String curlCmd = 'curl';
164-
curlCmd += ' -X ' + request.method;
164+
curlCmd += ' -X ${request.method}';
165165
bool compressed = false;
166166
request.headers.forEach((String name, String value) {
167167
if (name.toLowerCase() == 'accept-encoding' &&

packages/dart/lib/src/network/parse_live_query.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,20 +352,20 @@ class LiveQueryClient {
352352
final QueryBuilder query = subscription.query;
353353
final List<String>? keysToReturn = query.limiters['keys']?.split(',');
354354
query.limiters.clear(); //Remove limits in LiveQuery
355-
final String _where = query.buildQuery().replaceAll('where=', '');
355+
final String where = query.buildQuery().replaceAll('where=', '');
356356

357357
//Convert where condition to Map
358-
Map<String, dynamic> _whereMap = <String, dynamic>{};
359-
if (_where != '') {
360-
_whereMap = json.decode(_where);
358+
Map<String, dynamic> whereMap = <String, dynamic>{};
359+
if (where != '') {
360+
whereMap = json.decode(where);
361361
}
362362

363363
final Map<String, dynamic> subscribeMessage = <String, dynamic>{
364364
'op': 'subscribe',
365365
'requestId': subscription.requestId,
366366
'query': <String, dynamic>{
367367
'className': query.object.parseClassName,
368-
'where': _whereMap,
368+
'where': whereMap,
369369
if (keysToReturn != null && keysToReturn.isNotEmpty)
370370
'fields': keysToReturn
371371
}

packages/dart/lib/src/network/parse_query.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class QueryBuilder<T extends ParseObject> {
2727
if (i > 0) {
2828
query += ',';
2929
}
30-
query += '{' + list[i].buildQueries(list[i].queries) + '}';
30+
query += '{${list[i].buildQueries(list[i].queries)}}';
3131
}
3232
query += ']';
3333
queries.add(MapEntry<String, dynamic>(_noOperatorNeeded, query));
@@ -523,7 +523,7 @@ class QueryBuilder<T extends ParseObject> {
523523
String getLimiters(Map<String, dynamic> map) {
524524
String result = '';
525525
map.forEach((String key, dynamic value) {
526-
result = result + '&$key=$value';
526+
result = '$result&$key=$value';
527527
});
528528
return result;
529529
}
@@ -533,7 +533,7 @@ class QueryBuilder<T extends ParseObject> {
533533
String result = '';
534534
map.forEach((String key, dynamic value) {
535535
if (result.isNotEmpty) {
536-
result = result + ',"$key":$value';
536+
result = '$result,"$key":$value';
537537
} else {
538538
result = '"$key":$value';
539539
}

packages/dart/lib/src/objects/parse_object.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class ParseObject extends ParseBase implements ParseCloneable {
226226
final String parsePath = tempUri.path;
227227
final dynamic request = <String, dynamic>{
228228
'method': method,
229-
'path': '$parsePath$_path' + (objectId != null ? '/$objectId' : ''),
229+
'path': '$parsePath$_path${objectId != null ? '/$objectId' : ''}',
230230
'body': toJson(forApiRQ: true)
231231
};
232232
return request;

0 commit comments

Comments
 (0)