Skip to content

Commit 39db1aa

Browse files
null safety and packages update
1 parent 4780502 commit 39db1aa

File tree

6 files changed

+61
-91
lines changed

6 files changed

+61
-91
lines changed

example/fetch_products.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MyApp extends StatelessWidget {
1717
}
1818

1919
class MyHomePage extends StatefulWidget {
20-
MyHomePage({Key key, this.title}) : super(key: key);
20+
MyHomePage({Key? key, required this.title}) : super(key: key);
2121

2222
final String title;
2323

lib/query_string.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class QueryString {
1212

1313
// Go through all the matches and build the result map.
1414
for (Match match in search.allMatches(query)) {
15-
result[decode(match.group(1))] = decode(match.group(2));
15+
result[decode(match.group(1) ?? 'null')] =
16+
decode(match.group(2) ?? 'null');
1617
}
1718

1819
return result;

lib/woocommerce_api.dart

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ library woocommerce_api;
33
import 'dart:async';
44
import "dart:collection";
55
import 'dart:convert';
6+
import "dart:core";
67
import 'dart:io';
78
import "dart:math";
8-
import "dart:core";
9+
910
import 'package:crypto/crypto.dart' as crypto;
10-
import 'package:flutter/foundation.dart';
11-
import 'package:woocommerce_api/query_string.dart';
1211
import 'package:http/http.dart' as http;
12+
import 'package:woocommerce_api/query_string.dart';
1313
import 'package:woocommerce_api/woocommerce_error.dart';
1414

1515
/// [url] is you're site's base URL, e.g. `https://www.yourdomain.com`
@@ -23,17 +23,13 @@ class WooCommerceAPI {
2323
String url;
2424
String consumerKey;
2525
String consumerSecret;
26-
bool isHttps;
26+
late bool isHttps;
2727

2828
WooCommerceAPI({
29-
@required String url,
30-
@required String consumerKey,
31-
@required String consumerSecret,
29+
required this.url,
30+
required this.consumerKey,
31+
required this.consumerSecret,
3232
}) {
33-
this.url = url;
34-
this.consumerKey = consumerKey;
35-
this.consumerSecret = consumerSecret;
36-
3733
if (this.url.startsWith("https")) {
3834
this.isHttps = true;
3935
} else {
@@ -168,7 +164,7 @@ class WooCommerceAPI {
168164
String url = this._getOAuthURL("GET", endPoint);
169165

170166
try {
171-
final http.Response response = await http.get(url);
167+
final http.Response response = await http.get(Uri.parse(url));
172168
if (response.statusCode == 200) {
173169
return json.decode(response.body);
174170
}

lib/woocommerce_error.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
class WooCommerceError {
2-
String _code;
3-
String _message;
4-
Data _data;
2+
late String _code;
3+
late String _message;
4+
Data? _data;
55

6-
WooCommerceError({String code, String message, Data data}) {
6+
WooCommerceError(
7+
{required String code, required String message, Data? data}) {
78
this._code = code;
89
this._message = message;
910
this._data = data;
@@ -17,14 +18,14 @@ class WooCommerceError {
1718

1819
@override
1920
String toString() {
20-
return "WooCommerce Error!\ncode: $_code\nmessage: $_message\nstatus: ${_data.status}";
21+
return "WooCommerce Error!\ncode: $_code\nmessage: $_message\nstatus: ${_data?.status}";
2122
}
2223
}
2324

2425
class Data {
25-
int _status;
26+
late int _status;
2627

27-
Data({int status}) {
28+
Data({required int status}) {
2829
this._status = status;
2930
}
3031

pubspec.lock

Lines changed: 39 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
# Generated by pub
22
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
4-
archive:
5-
dependency: transitive
6-
description:
7-
name: archive
8-
url: "https://pub.dartlang.org"
9-
source: hosted
10-
version: "2.0.11"
11-
args:
12-
dependency: transitive
13-
description:
14-
name: args
15-
url: "https://pub.dartlang.org"
16-
source: hosted
17-
version: "1.5.2"
184
async:
195
dependency: transitive
206
description:
217
name: async
228
url: "https://pub.dartlang.org"
239
source: hosted
24-
version: "2.4.0"
10+
version: "2.5.0"
2511
boolean_selector:
2612
dependency: transitive
2713
description:
2814
name: boolean_selector
2915
url: "https://pub.dartlang.org"
3016
source: hosted
31-
version: "1.0.5"
17+
version: "2.1.0"
18+
characters:
19+
dependency: transitive
20+
description:
21+
name: characters
22+
url: "https://pub.dartlang.org"
23+
source: hosted
24+
version: "1.1.0"
3225
charcode:
3326
dependency: transitive
3427
description:
3528
name: charcode
3629
url: "https://pub.dartlang.org"
3730
source: hosted
38-
version: "1.1.2"
39-
collection:
31+
version: "1.2.0"
32+
clock:
4033
dependency: transitive
4134
description:
42-
name: collection
35+
name: clock
4336
url: "https://pub.dartlang.org"
4437
source: hosted
45-
version: "1.14.11"
46-
convert:
38+
version: "1.1.0"
39+
collection:
4740
dependency: transitive
4841
description:
49-
name: convert
42+
name: collection
5043
url: "https://pub.dartlang.org"
5144
source: hosted
52-
version: "2.1.1"
45+
version: "1.15.0"
5346
crypto:
5447
dependency: "direct main"
5548
description:
5649
name: crypto
5750
url: "https://pub.dartlang.org"
5851
source: hosted
59-
version: "2.1.3"
52+
version: "3.0.1"
53+
fake_async:
54+
dependency: transitive
55+
description:
56+
name: fake_async
57+
url: "https://pub.dartlang.org"
58+
source: hosted
59+
version: "1.2.0"
6060
flutter:
6161
dependency: "direct main"
6262
description: flutter
@@ -73,63 +73,42 @@ packages:
7373
name: http
7474
url: "https://pub.dartlang.org"
7575
source: hosted
76-
version: "0.12.0+4"
76+
version: "0.13.1"
7777
http_parser:
7878
dependency: transitive
7979
description:
8080
name: http_parser
8181
url: "https://pub.dartlang.org"
8282
source: hosted
83-
version: "3.1.3"
84-
image:
85-
dependency: transitive
86-
description:
87-
name: image
88-
url: "https://pub.dartlang.org"
89-
source: hosted
90-
version: "2.1.4"
83+
version: "4.0.0"
9184
matcher:
9285
dependency: transitive
9386
description:
9487
name: matcher
9588
url: "https://pub.dartlang.org"
9689
source: hosted
97-
version: "0.12.6"
90+
version: "0.12.10"
9891
meta:
9992
dependency: transitive
10093
description:
10194
name: meta
10295
url: "https://pub.dartlang.org"
10396
source: hosted
104-
version: "1.1.8"
97+
version: "1.3.0"
10598
path:
10699
dependency: transitive
107100
description:
108101
name: path
109102
url: "https://pub.dartlang.org"
110103
source: hosted
111-
version: "1.6.4"
104+
version: "1.8.0"
112105
pedantic:
113106
dependency: transitive
114107
description:
115108
name: pedantic
116109
url: "https://pub.dartlang.org"
117110
source: hosted
118-
version: "1.8.0+1"
119-
petitparser:
120-
dependency: transitive
121-
description:
122-
name: petitparser
123-
url: "https://pub.dartlang.org"
124-
source: hosted
125-
version: "2.4.0"
126-
quiver:
127-
dependency: transitive
128-
description:
129-
name: quiver
130-
url: "https://pub.dartlang.org"
131-
source: hosted
132-
version: "2.0.5"
111+
version: "1.11.0"
133112
sky_engine:
134113
dependency: transitive
135114
description: flutter
@@ -141,62 +120,55 @@ packages:
141120
name: source_span
142121
url: "https://pub.dartlang.org"
143122
source: hosted
144-
version: "1.5.5"
123+
version: "1.8.0"
145124
stack_trace:
146125
dependency: transitive
147126
description:
148127
name: stack_trace
149128
url: "https://pub.dartlang.org"
150129
source: hosted
151-
version: "1.9.3"
130+
version: "1.10.0"
152131
stream_channel:
153132
dependency: transitive
154133
description:
155134
name: stream_channel
156135
url: "https://pub.dartlang.org"
157136
source: hosted
158-
version: "2.0.0"
137+
version: "2.1.0"
159138
string_scanner:
160139
dependency: transitive
161140
description:
162141
name: string_scanner
163142
url: "https://pub.dartlang.org"
164143
source: hosted
165-
version: "1.0.5"
144+
version: "1.1.0"
166145
term_glyph:
167146
dependency: transitive
168147
description:
169148
name: term_glyph
170149
url: "https://pub.dartlang.org"
171150
source: hosted
172-
version: "1.1.0"
151+
version: "1.2.0"
173152
test_api:
174153
dependency: transitive
175154
description:
176155
name: test_api
177156
url: "https://pub.dartlang.org"
178157
source: hosted
179-
version: "0.2.11"
158+
version: "0.2.19"
180159
typed_data:
181160
dependency: transitive
182161
description:
183162
name: typed_data
184163
url: "https://pub.dartlang.org"
185164
source: hosted
186-
version: "1.1.6"
165+
version: "1.3.0"
187166
vector_math:
188167
dependency: transitive
189168
description:
190169
name: vector_math
191170
url: "https://pub.dartlang.org"
192171
source: hosted
193-
version: "2.0.8"
194-
xml:
195-
dependency: transitive
196-
description:
197-
name: xml
198-
url: "https://pub.dartlang.org"
199-
source: hosted
200-
version: "3.5.0"
172+
version: "2.1.0"
201173
sdks:
202-
dart: ">=2.6.0 <3.0.0"
174+
dart: ">=2.12.0 <3.0.0"

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ homepage: https://github.com/samarthagarwal/woocommerce_dart
77
dependencies:
88
flutter:
99
sdk: flutter
10-
crypto: ^2.1.3
11-
http: ^0.12.0+4
10+
crypto: ^3.0.1
11+
http: ^0.13.1
1212

1313
dev_dependencies:
1414
flutter_test:
@@ -17,4 +17,4 @@ dev_dependencies:
1717
flutter:
1818

1919
environment:
20-
sdk: ">=2.6.0 <3.0.0"
20+
sdk: ">=2.12.0 <3.0.0"

0 commit comments

Comments
 (0)